PromiseRejectionEvent: promise property - Web APIs | MDN (original) (raw)
Value
The JavaScript Promise which was rejected, and whose rejection went unhandled.
Examples
This example listens for unhandled promises and, if thereason is an object with acode field containing the text "Module not ready", it sets up an idle callback that will retry the task that failed to execute correctly.
event.preventDefault() is called to indicate that the promise has now been handled.
js
window.onunhandledrejection = (event) => {
if (event.reason?.code === "Module not ready") {
requestIdleCallback((deadline) => {
loadModule(event.reason.moduleName).then(performStartup);
});
event.preventDefault();
}
};
Specifications
| Specification |
|---|
| HTML # dom-promiserejectionevent-promise |