1

I am trying to load a page which is built using react. when the page loads there is a table which is rendered using react. this table doesn't load currently on IE and throws error promise is not defined. the exact same code with promise works on other browsers. below is the code.

fetchData(url) {
    // Return a new promise.
    return new Promise(function (resolve, reject) {
        $.ajax(
            {
                url: url,
                cache: false,
                context: this,
                dataType: 'json',   // we're expecting JSON as a response
                data: {},
                method: "GET",
                contentType: "application/json; charset=utf-8",
                success: function (data, status, xhr) {
                    resolve(JSON.parse(data));
                },
                error: function (xhr, status, httpErrorText) {
                    reject(httpErrorText);
                }
            });
    });
}

any ideas why this is happening and how to fix this.

hussian
  • 399
  • 6
  • 19
  • Possible duplicate of [is there a way to implement promises in ie9+](https://stackoverflow.com/questions/27835687/is-there-a-way-to-implement-promises-in-ie9) – Devon Bessemer Aug 23 '18 at 13:34
  • 1
    Possible duplicate of [How to make promises work in IE11](https://stackoverflow.com/questions/36016327/how-to-make-promises-work-in-ie11) –  Aug 23 '18 at 13:35
  • I have a jsx file where I can't reference the cdn directly so the suggested answers don't work well for me. – hussian Aug 23 '18 at 14:08
  • Did you look at the @reiner.luke link? You could just use an external promise library. – Devin Fields Aug 23 '18 at 14:48
  • I did however in my code I have lots of lets and arrow functions so I can't change them all. – hussian Aug 24 '18 at 08:05

1 Answers1

1

I had the same issue. I added the following line in public/index.html which fixed all IE11 polyfills and it worked:

<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6"></script>
Victor Karangwa
  • 1,679
  • 20
  • 16