-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Error: the promise constructor requires a resolver function
benjamingr edited this page Feb 6, 2014
·
2 revisions
Error: the promise constructor requires a resolver function
You got this error because you used new Promise()
or new Promise(something)
without passing a function as the parameter.
If you want to wrap an API with a promise manually, the correct syntax is:
function wrapWithPromise(parameter) {
return new Promise(function (resolve, reject) {
doSomethingAsync({
error:reject,
success:resolve
});
});
}
Please consider reading more about it and also consider checking out automatic promisification as well as Promise.method