DEV Community

Mayank
Mayank

Posted on

Answer: How to return streams from node js with openai

From your code, I see that you are returning a JSON response from the API. Not sure why you are trying to parse it as text on client side.

Please try following

 const controller = new AbortController()
    const response = await fetch(endpoint, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },

Top comments (0)