Fetch polyfill in React not completely working in IE 11

前端 未结 4 506
刺人心
刺人心 2021-01-07 02:53

This fetch works fine in Chrome:

fetch( this.props.url, {credentials:\'same-origin\'})
    .then( (data) => data.js         


        
4条回答
  •  时光取名叫无心
    2021-01-07 03:43

    You need to include the following files in order for fetch.js to work inside IE 11+

    • './node_modules/es6-promise/dist/es6-promise.auto.js'
    • 'isomorphic-fetch'

    Before running the webpack command you have to make sure you've installed these files in node_modules, run this:

    npm install --save isomorphic-fetch es6-promise

    then put this within webpack entry property:

      entry: [
        './node_modules/es6-promise/dist/es6-promise.auto.js',
        'isomorphic-fetch',
        'path for main file'
      ]
    

    Now type the webpack keyword in your terminal/cmd and you should have a file located in your dist folder (if you haven't specified some other output path) with the polyfill's available.

    Here is the official github fetch.js polyfill page

提交回复
热议问题