Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

async await catch error

async function f() {

  try {
    let response = await fetch('/no-user-here');
    let user = await response.json();
  } catch(err) {
    // catches errors both in fetch and response.json
    alert(err);
  }
}
Source by javascript.info #
 
PREVIOUS NEXT
Tagged: #async #await #catch #error
ADD COMMENT
Topic
Name
7+5 =