hussian
hussian

Reputation: 399

IE 11 react 'promise' is undefined

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.

Upvotes: 1

Views: 3211

Answers (1)

Victor Karangwa
Victor Karangwa

Reputation: 2216

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>

Upvotes: 1

Related Questions