javascript promise catch error code example
Example: promise catch javascript
// errors that occur in asynchronous code inside promises cannot be caught with regular try/catch
// you need to pass the error handler into `.catch()`
fetchUserData(userId).then(console.log).catch(handleError);