Fetch: Usage with babel and ES6

Created on 9 Feb 2016  路  4Comments  路  Source: github/fetch

I try to use the package with babel and es6
import fetch from 'whatwg-fetch';

Unfortunately I get the following error:

Uncaught TypeError: (0 , _whatwgFetch2.default) is not a function

Most helpful comment

@abimelex
Description

A window.fetch JavaScript polyfill.

fetch do not export modules.
You can do

import 'whatwg-fetch';
// And then just use global variable.
fetch(...);

All 4 comments

@abimelex
Description

A window.fetch JavaScript polyfill.

fetch do not export modules.
You can do

import 'whatwg-fetch';
// And then just use global variable.
fetch(...);

Ah thank you, thats perfect.

Don't forget to close issue if you found answers.

I solved it with import 'isomorphic-fetch'; in my jest-setup.js.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knowbody picture knowbody  路  5Comments

gkatsanos picture gkatsanos  路  4Comments

fczuardi picture fczuardi  路  3Comments

kocur4d picture kocur4d  路  3Comments

DimitryDushkin picture DimitryDushkin  路  4Comments