Async Error Handling
- async functions allow you to use normal try / catch with Promises
- If something throws in a try / catch while awaiting, you can handle it
async function serverCall() {
try {
const resp = await fetch("https://some-server.com")
const data = await resp.json();
console.log(data);
} catch(e) {
console.log("Something went wrong with your request!")
}
}
11 / 23