catch
A .catch() is really just a .then() without a slot for a callback function for the case when the promise is resolved. It is used to handle rejected promises.2
const promise1 = new Promise((resolve, reject) => {
throw 'An error occured';
});
promise1.catch(function (error) {
console.error(error);
});
// expected output: An error occured
References
Backlinks