1async function f() {
2
3 try {
4 let response = await fetch('/no-user-here');
5 let user = await response.json();
6 } catch(err) {
7 // catches errors both in fetch and response.json
8 alert(err);
9 }
10}
1var response = await promisedFunction().catch((err) => { console.error(err); });
2// response will be undefined if the promise is rejected
3// this will work instead of using try...catch...