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?

comments (single view)

fetch("https://api.wasteof.money/posts/64fa845c62c9b104f65962d4/").then(r => r.json()).then(j => document.querySelector("#the_element").innerHTML = j.content).catch(e => document.querySelector("#the_element").innerHTML = `<p>error: ${e}</p>`)

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

.catch(e => {
  console.dir(e);
  document.querySelector("#the_element").innerHTML = `<p>error: ${e}</p>`;
});

and then tell me what’s in the console?

ok i will

View all comments