Getting Error Promise is undefined in IE11

后端 未结 7 767
刺人心
刺人心 2020-12-24 11:29

I am converting React code to typescript, target in tsconfig is es5.

on running in IE 11 i get an error \"Promise is undefined\"

I know i need to polyfill,bu

7条回答
  •  猫巷女王i
    2020-12-24 11:32

    var ES6Promise = require("es6-promise");
    ES6Promise.polyfill();
    var axios = require("axios");
    

    writing this above axios worked for me maybe other options also worked

    it was mainly a cache issue in IE that i was facing

    installing es6-promise-promise webpack plugin also worked

    npm install es6-promise-promise
    

    and include

    new webpack.ProvidePlugin({
        Promise: 'es6-promise-promise', // works as expected
    });
    

    in webpack plugins

    i will edit this answer with more possible options

提交回复
热议问题