Can someone help me find out why my frontend wont display the fetched data from the OpenAI API?

The first picture is the JS file and the second is the frontend part. If tried everything but whenever I enter “hello” in the textbox i created, nothing is printed from the API. Im sure i fetched it correctly but idk. Can someone help me please

Here is the html file.

Here is the JS file

What error are you getting after you try to hit the API?

Is there an error happening?

No error. Just simply not printing on my webpage

Nothing in the console?


I was just testing it by opening up vscode liveserver. but by running node index.js this shows up

You’re not sending / setting your API key.

Take a few minutes to check out the outstanding OpenAI API Quickstart guide… That will run you through the basics. If you’re still having trouble, come back, and let us know your code and errors.

Nvm it worked. Thank you very much

1 Like