JavaScript Promise.reject() Method
The Promise.reject() static method returns a promise that is already rejected with a given reason.
Description
The Promise.reject() static method returns a promise that is rejected with the given reason. Use an Error object as the reason so a stack trace is available. Inside an async function, throw does the same thing.
Unlike Promise.resolve(), it doesn't unwrap promises: passing a promise as the reason makes that promise object the rejection reason. A rejected promise with no catch() or try...catch attached produces an "unhandled rejection" warning in the console.
It's useful in functions that return promises when validation fails early, so callers always handle errors the same way: if (!id) return Promise.reject(new TypeError('id is required')).
Syntax
Promise.reject(reason)Parameters
- reasonThe rejection reason, usually an
Error.
Return Value
A promise rejected with the reason.
Example
Browser Support
The following information will show you the current browser support for the Promise.reject() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





