I'm trying to use a promise but get a type error: Promise is not a constructor.
Here's the promise:
var Promise = new Promise(
function (resolve,error) {
for (var key in excludeValues) {
/* some ifs */
minVal = someValue
........
........
}
resolve(errors)
});
Promise.then(
function(data){
if (minVal > maxVal)
{
errors.minMax.push(
'minMax'
)
}
if (gapVal > minVal * -1)
{
errors.minMax.push(
'gapVal'
)
}
return (errors.minMax.length == 0 && errors.zahl.length == 0 && errors.hoch.length == 0 && errors.niedrig.length == 0)
}
);
Can someone tell me what I'm doing wrong?
With var Promise
you declare a local variable in your scope. It is initialised with undefined
and shadows the global Promise
constructor. Use a different variable name
var promise = new Promise(…);
promise.then(…);
or none at all
new Promise(…).then(…);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With