Sending headers

 let url = "https://icanhazdadjoke.com/";


async function getJoke() {
  try {
    const config = {
      headers: {
        Accept: "application/json"
      },
    };
    let res = await axios.get(url, config);
    console.log(res.data);
    console.log(res.data.joke);

  } catch (e) {
    console.log(e);
  }
}

getJoke();

Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code