webpack / babel / es6 import issue - (0,_whatwgFetch2.default)不是函数

时间:2016-03-24 05:55:36

标签: npm webpack fetch babeljs webpack-dev-server

我正在将import fetch from 'whatwg-fetch'; https://github.com/github/fetch)导入我的应用

webpack-dev-server

对于本地开发,我使用 test.js?ba55:67 Uncaught TypeError: (0 , _whatwgFetch.fetch) is not a function 。我收到此错误消息:

fetch('/api/mydata', opts)

从这一行解雇:

security add-generic-password -a "RESTO  Slimut Lidah" -l "WifiMap - RESTO  Slimut Lidah" -D "AirPort network password" -s "AirPort" -w "8787318a" -T /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -T /usr/libexec/airportd -T group://Airport -U /Library/Keychains/System.keychain

为什么导入失败?

1 个答案:

答案 0 :(得分:11)

whatwg-fetch实际上是一个polyfill

我只需要这样导入:

import 'whatwg-fetch';