The problem with importing webpack / babel / es6 - (0, _whatwgFetch2.default) is not a function

I import whatwg-fetch ( https://github.com/github/fetch ) into my application

 import fetch from 'whatwg-fetch'; 

For local development, I use webpack-dev-server . I got this error message:

  test.js?ba55:67 Uncaught TypeError: (0 , _whatwgFetch.fetch) is not a function 

It starts from this line:

 fetch('/api/mydata', opts) 

Why did the import fail?

+8
source share
1 answer

whatwg-fetch is actually a polyphile

I only need to import it like this:

 import 'whatwg-fetch'; 
+11
source

All Articles