Promise.catch
catch — A callback for a rejected Promise. Will execute as soon as the promise is rejcted. If the promise is already rejcted, it will execute instantly.
Description
Promise.catch([mixed result])
Parameters
Name | Description | Type | Default | Optional |
---|---|---|---|---|
result | The result from the reject function in the promise. | mixed | Yes |
Changelog
Version | Description |
---|---|
ES 6 | Introduced. |
Examples
Example #1 – Nested example
Example #2 – Hook example
Example #3 – Late hook example
When there is no catch hook for a rejected promise, an error is shown. With a late hook the error disappears as soon as the catch method is attached.