can someone PLEASE give me some vanilla javascript code that will make a get request to https://api.wasteof.money/posts/64fa845c62c9b104f65962d4/ and display it as an <p> element on screen?
currently not on my computer, but essentially you have to use fetch to get the content of https://api.wasteof.money/posts/64fa845c62c9b104f65962d4/, and then set the .innerHTML of an element to the post.content
here’s an example of it: https://git.tnix.dev/Tnix/random/src/branch/main/wasteof/example-64fa922ea5efdaee65509cce.html
btw the API has CORS, so requests to the API from another website will fail, you’d have to use something like a browser extension to bypass CORS policies, but I don’t recommend that for security reasons.
oh, thanks. If you have time later, can you provide a code snippet for making the fetch request? I can do the inter html part
I would but I don't have my computer on this trip. @jeffalo can you help them, you definitely know how to do it
thanks
hey im dumb how do i make #the_element? do i add “class=’#the_element’”?
no, # is for id (i.e.,
id="the_element). classes begin with . as opposed to #oh ok i kinda forget some things after 3 months of not programming
TypeError: Failed to fetch
can you change the catch part to
and then tell me what’s in the console?
ok i will