fetch method is not defined using ES6 fetch in React

十年热恋 提交于 2019-12-03 11:43:15

It's an exported default, so...

import fetch from 'isomorphic-fetch'

Adding a polyfill for this is the correct approach. Looking at one of my latest projects you just need to do the following imports;

import promise from 'es6-promise';
import 'isomorphic-fetch';

promise.polyfill();

It looks like you've not quite got the es6-promise import correct which requires the .polyfill() method be called. I'd recommend putting these in the entry point of the application as you should only need to import them once.

I'd also recommend you include the babel polyfill;

import 'babel-polyfill';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!