#Can't push GET data to HTML

8 messages · Page 1 of 1 (latest)

lone junco
#

I can't seem to get the data from an API and put it on the site, and unfortunately I don't know enough JS to figure it out

Photos related

#

The message got taken down because of too many attachments

cursive stirrupBOT
#

See #faq to learn how to properly share code on Discord: #faq message

remote panther
#

#faq has good resources to learn js.

There are a number of things wrong or just bad practices. But the root issues are you're attempting to access data outside the scope of your event listener callback function when you instantiated it. So it's undefined. In addition it's asynchronously being fetched and you're trying to access it outside of your .then callback (stop using these, async/await ftw).

Also don't use innerHTML, textContent is all you need.