Node 7.1.0 new Promise() resolver undefined is not a function

The API for promises requires you to pass a function to the promise constructor. Quoting MDN:

new Promise( /* executor */ function(resolve, reject) { … } );

executor – A function that is passed with the arguments resolve and reject. The executor function is executed immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise constructor even returns the created object). The resolve and reject functions, when called, resolve or reject the promise respectively. The executor normally initiates some asynchronous work and then, once that completes, calls either the resolve or reject function to resolve the promise or else reject it if an error occurred.

You can see this answer for usage examples.

Node 7.1 supports promises.

Leave a Comment

File not found.