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

import fetch from 'whatwg-fetch'

store.fetchItems = (api) => {
  return fetch(api, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    mode: 'no-cors'
  }).then(res => {
    if (res.status >= 200 && res.status < 300) {
      return Promise.resolve(res)
    } else {
      return Promise.reject(new Error(res.statusText))
    }
  }).then(res => {
    return res.json()
  }).then(data => {
    return data
  }).catch(err => {
    console.log(err)
  })
}

Some error occurs in browser under Babel6:

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

Author: Fantashit

2 thoughts on “Uncaught TypeError: (0 , _whatwgFetch2.default) is not a function

  1. Is it the same case with import fetch from ‘isomorphic-fetch’
    Do I have to just include : import ‘isomorphic-fetch’ instead

Comments are closed.