JavaScript Promise.prototype.catch() Method
The catch() method registers a function to handle a promise's rejection, such as a failed network request.
Description
The catch() method schedules a function to run if the promise is rejected. It's shorthand for then(undefined, onRejected). Placed at the end of a chain, it catches an error from any earlier step. The returned promise fulfills with whatever the handler returns, so the chain can recover and continue.
A common mistake is forgetting to return the value or rethrow inside catch(): returning nothing makes the chain continue with undefined as if everything were fine. If the error can't be handled at this point, throw it again so code further along knows the operation failed.
With async functions, try...catch around await does the same job. Adding a catch() to promises you don't await prevents "unhandled promise rejection" warnings.
Syntax
promise.catch(onRejected)Parameters
- onRejectedA function called with the reason when the promise rejects.
Return Value
A new promise.
Example
Browser Support
The following information will show you the current browser support for the Promise.prototype.catch() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





