Search code examples
javascriptpromisees6-promise

Uncaught TypeError: Promise.reject is not a constructor


I had a problem;

const p4 = new Promise.reject("Error"); 

or

const p4 = new Promise.resolve("Sucess"); 

I get such an error when defining;

Uncaught TypeError: Promise.reject is not a constructor

There shouldn't be any errors.


Solution

  • Here is how you can fix the error. The issue is with the new keyword.

    Promise.reject is a static methods rejects Promises directly so you should not use the new keyword with them.

    here is documentation of Promises