I’m trying to make a call to ChatGPT API. Here’s the code:
const response = await fetch(‘https://api.openai.com/v1/chat/completions’, {
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
: Headers {}
ok : true
redirected: false
status: 200
statusText: “”
type: “cors”
url : “https://api.openai.com/v1/chat/completions”
Any idea on how to fix this?