randomPromise .then(()=>{ //do something }) .catch(()=>{ //an error has occurred })
async function fetchData(){ try{ await fetch({/*some options*/}) } catch(err){ //handle an error } //this code will NOT run until a response is received from the fetch request //or an error occurs }