🔰error handling
JS ⟩ async ⟩ Promise ⟩ error handling
⬆️ require: getJSON()
// use second callback parameter to handle errors.
getJSON("/api/user/profile")
.then(doThisIfFulfilled, doThisIfRejected);
// use .catch() (more idiomatic way)
getJSON("/api/user/profile")
.then(displayUserProfile)
.catch(profileError);Last updated
Was this helpful?