Solve - Promise.resolve is not a constructor Error in JS


Borislav Hadzhiev

Last updated: Oct 19, 2021


Check out my new book

Solve - Promise.resolve is not a constructor Error #

The "Promise.resolve is not a constructor" error occurs when we try to use the Promise.resolve() method with the new operator. The Promise.resolve() method is not a constructor so it should be used without the new operator, e.g. Promise.resolve('example').

promise resolve is not a constructor

Here's an example of how the error is caused.

// ⛔️ Promise.resolve is not a constructor const err = new Promise.resolve('example');

Instead, we should not use the new operator with the Promise.resolve method.

// ✅ works const resolved = Promise.resolve('example');

Promise.resolve is a method, not a constructor. The only parameter the method takes is the value to be resolved by the promise.

The Promise.resolve() method returns a promise that is resolved with the provided value.

Note that as opposed to the Promise.resolve method, Promise() is a constructor which is used to wrap functions that don't already support promises.

The following 2 examples achieve the same result:

const r1 = Promise.resolve('example'); const r2 = new Promise((resolve, reject) => { resolve('example'); });

Both of the variables store a fulfilled promise, however the Promise.resolve method provides us a more direct and concise solution than the Promise() constructor for this use case.

Use the search field on my Home Page to filter through my more than 3,000 articles.