Promise.reject()
ES6+Returns a Promise object that is rejected with the given reason.
Syntax
Promise.reject(reason)Parameters
reason any The reason for rejecting the Promise
Return Value
Promise
A Promise that is rejected with the given reason
Examples
JavaScript
Promise.reject(new Error('Something went wrong'))
.catch(error => console.log(error.message)); Output:
// 'Something went wrong'