Reputation: 40674
I am importing whatwg-fetch
(https://github.com/github/fetch) into my app
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 is fired from this line:
fetch('/api/mydata', opts)
Why the import failed?
Upvotes: 9
Views: 1698
Reputation: 40674
whatwg-fetch
is actually a polyfill
I only need to import it this way:
import 'whatwg-fetch';
Upvotes: 12