Let's answer the following questions to help our knowledge of what we have just learned stick:
- What will the output be in the console if we ran the following code in a browser?
try {
setInterval(() => {
throw new Error("Oops");
}, 1000);
} catch (ex) {
console.log("Sorry, there is a problem", ex);
}
- Assuming that post 9999 doesn't exist, what would be the output in the console if we ran the following code in a browser?
fetch("https://jsonplaceholder.typicode.com/posts/9999")
.then(response => {
console.log("HTTP status code", response.status);
return response.json();
})
.then(data => console.log("Response body", data))
.catch (error => console.log("Error", error));
- If we did a similar exercise with axios, what would be the output in the console when running the following...