Advanced Fetch

  • The fetch function lets you provide all of the request properties mentioned...
  • Method, Headers, Body, etc
  • You can read most of the parts of the response
  • This is important for reading from some APIs
fetch("https://icanhazdadjoke.com", { method: "GET", headers: { ["Accept"]: "application/json" } })
    .then(resp => resp.json())
    .then(console.log)

19 / 25