Talking to the internet
Weather apps, maps, news feeds — they all ask other computers for data. Those computers offer an API: a set of web addresses you can request data from. JavaScript asks with fetch.
fetch with async/await
async function getJoke() {
const response = await fetch("https://official-joke-api.appspot.com/random_joke");
const joke = await response.json();
console.log(joke.setup);
console.log("…" + joke.punchline);
}
getJoke();Sikau's practice space can only fetch from a few friendly practice APIs, like dummyjson.com and official-joke-api.appspot.com.