Standard built-ins
Promise.prototype.catch()
Attaches a rejection reaction. A normal return recovers the downstream promise; throwing or returning a rejection propagates failure.
Formal Syntax & Structure
javascript syntaxjavascript
promise.catch(onRejected)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| onRejected | function | Receives the rejection reason. |
Return Value
Promise
Downstream promise.
Working Example
Example Snippetjavascript
Promise.reject("failed").catch(reason => reason.length).then(console.log);