#How can I remove "undefined"?
10 messages · Page 1 of 1 (latest)
How does the code look that prints the response?
I'm not sure about what can be changed in the code, do you spot a mistake here? @frosty tide
resultRef.current is, on the first "message" event, undefined. And something undefined plus a string is "undefinedplusastring". Lastly I'm guessing that the text variable (at line 90) might also be undefined in the last message event.
So initially set resultRef.current to an empty string, before you rend the API request 🙂
The tailing "undefined" is not entirely clear to me.
This is wrong?
Unsure 🤷♂️ my React is not strong. I do very well with general Javascript though 🙂
I fig it out, I had to add an if statement as a filter to only show arrays from openai api which had content field in it. That removed the undefined part. Thank you!