Promise.reject()

Returns a promise that is rejected with the given reason.

Since ES2015 (ES6) Spec ↗

Syntax

Promise.reject(reason)

Returns

Promise — A promise rejected with `reason`.

Examples

Promise.reject(new Error("nope"))
  .catch(e => console.log(e.message));
Output
nope
Promise.reject("plain reason")
  .catch(r => console.log(r));
Output
plain reason

Notes

- Unlike `Promise.resolve()`, the reason is not unwrapped even if it is a promise. - Prefer rejecting with an `Error` instance for useful stack traces.

Browser & runtime support

EnvironmentSince version
chrome 32
firefox 29
safari 8
edge 12
node 0.12

See also