apparenlty ie11 does not support Promises so I get this issue:
SCRIPT5009: 'Promise' is undefined
File: fetch.js, Line: 244, Column: 5
return new Promise(function(resolve, reject) { <=====
var xhr = new XMLHttpRequest()
if (self.credentials === 'cors') {
xhr.withCredentials = true;
}
function responseURL() {
if ('responseURL' in xhr) {
return xhr.responseURL
}
I think the recommendation is that developers should use a promise polyfill in conjunction with fetch (fetch shouldn't provide the polyfill itself). At my company we use either polyfill.io for this (e.g.) or ES6-Promise.
The promise polyfill is documented in the readme. We use e6-promise at GitHub.
I've included the es6-promise:
<script src="javascripts/vendor/fetch/fetch.js"></script>
<script src="javascripts/vendor/es6-promise/promise.js"></script>
file, but get the same error.
Dependencies must be included in order. Try moving the promise include above fetch.
didn't matter what order I put it in.. The result was the same.
I dug around the es6-promise closed issues and someone mentioned to add this line:
ES6Promise.polyfill()
now it works.
We use the pre-2.0 version of es6-promise because they broke it in v2.0: https://github.com/jakearchibald/es6-promise/issues/75
The above combination worked for me
import ES6Promise from 'es6-promise';
ES6Promise.polyfill();
This is not working for me. How can I fix the undefined Promise problem? I'm using the latest version of es6-promise.
Mark Horsman
Please note es6-promise is not required if you use babel+babel-runtime or babel+babel-polyfill,
The key is you MUST compile whatwg-fetch with babel so that fetch knows the babel's Promise.
Here is the snippet from my webpack.config.js,
module.exports = {
module: {
loaders: [
test: /\.jsx*$/,
// whatwg-fetch is excluded too, unfortunately.
exclude: [/node_modules/, /.+\.config.js/],
loader: 'babel'
}, {
// whatwg-fetch use Promsie which IE11 doesn't support
test: /\.js$/,
include: [/whatwg-.*/],
loader: 'babel'
}
]
}
};
@kairi1227 I have imported as below after installed the using command npm install es6-promise
import ES6Promise from "es6-promise";
and I am getting an error saying "../node_modules/es6-promise/es6-promise" has no default export.
Please can you help me.
import { polyfill } from 'es6-promise'; polyfill();
Solved the purpose in my case.
Most helpful comment
didn't matter what order I put it in.. The result was the same.
I dug around the es6-promise closed issues and someone mentioned to add this line:
now it works.