Last updated 2 years ago
Was this helpful?
⟩ ⟩ ⟩ error handling
catch await errors by try...catch.
(async () => { // catch await errors by try...catch statement. try { let response = await fetch(url); } catch(err) { console.log(err); } })();
catch async function errors by .
(async () => { let response = await fetch(url); })().catch(err => { // catch a rejected Promise returned by async func console.log(err) });
JS.info ⟩
Promise ⟩ error handling