How to solve? Response {type: 'cors', url: ''

I’m trying to make a call to ChatGPT API. Here’s the code:

const response = await fetch(‘’, {
headers: {
‘Content-Type’: ‘application/json’,
Authorization: 'Bearer ’ + ‘api’,
method: ‘POST’,
body: JSON.stringify({
model: ‘gpt-3.5-turbo’,
messages: [
role: ‘user’,
content: ‘Hola’,

And this is the response I get:

body : ReadableStream
bodyUsed: false
: Headers {}
ok : true
redirected: false
status: 200
statusText: “”
type: “cors”
url : “

Any idea on how to fix this?

You didn’t provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you’re accessing the API from your browser and are prompted for a username and password. You can obtain an API key from OpenAI Platform",