"'Promise' is undefined" in IE11
bengtmoss opened this issue · 6 comments
I'm testing the pnp.js of the latest PnP-JS-Core, using an Install and Use example
The example includes the use of promise. The instructions say that this will fail in IE11 unless I add the es6-promise polyfill and the fetch polyfill and include them in the example.
So I did, but in IE11, when invoking the invocation of "then":
$pnp.sp.web.select("Title").get()
.then(function (data) {
document.getElementById("main").innerText = 'Web title: ' + data.Title;
})
.catch(function (ex) {
document.getElementById("main").innerText = 'Exception: ' + ex;
});
still fails with the exception: "'Promise' is undefined".
Any suggestions why that might be?
I have the same problem with IE11. The same code runs correct in Firefox. I swich featch/es6 loading and test minimal versions. :/
I'd blame the fetch polyfill. Using the promise polyfill here also with IE 10/11 and no problems.
Hi, I think you need to use the auto file for automatic polyfilling.
The other file just exports the Promise method (window.ES6Promise) but does not set window.Promise variable.
This is done because when you have multiple dependencies each having their own version/spec of Promise implementation where you don't want to pollute the global environment with one particular version. So this is left to the developer to choose what variable he wishes to define as what Promise spec.
I'm getting an error in IE 11: Expected identifier (1075,21) IE 11 has a bug in it's JS engine (at least on my machine it does) where catch is not interpreted as a function name, but as a try{}catch(){} and is failing...
Promise.prototype.catch = function _catch(onRejection) {
return this.then(null, onRejection);
};
If I fix that error, I also get the same error on the finally.
Maybe this is due to compatibility mode?
Am I doing something wrong?
I'm getting an error in IE 11: Expected identifier (1075,21) IE 11 has a bug in it's JS engine (at least on my machine it does) where catch is not interpreted as a function name, but as a try{}catch(){} and is failing...
Promise.prototype.catch = function _catch(onRejection) { return this.then(null, onRejection); };
If I fix that error, I also get the same error on the finally.
Maybe this is due to compatibility mode?
Am I doing something wrong?
Looks like this was an IE Compatibility issue. The minified or the es6-promises actually does have the ["catch"] and ["finally"] values defined correctly.
Seems I maybe do not have the latest version here, "catch" needs to be a quoted property:
Promise.prototype['catch'] = ...