-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Error: Illegal resolve reject invocation
benjamingr edited this page Dec 21, 2014
·
2 revisions
ERROR: Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.
This happens when using the deprecated old defer()
api but calling the resolve
and reject
function not as a method - for example:
var d = Promise.defer();
d.resolve(); // this is fine
var copy = resolve;
resolve(); // Throws the above error, use `function(){ d.resolve(); }` instead.
This might happen when doing something like:
myCallBackAPI("param", d.resolve);
In which case consider using the promise constructor that doesn't have this problem, using Function.prototype.bind
or using automatic promisification if applicable.