It's a polyfill, so you should never need to import it with a name, just like you never need to do import Promise from 'es6-promise'.
But if you insist, it should be doable currently
import * as fetch from 'whatwg-fetch';
import {fetch} from 'whatwg-fetch';
It might be a little cumbersome but something like this could work:
Make a little fetch utility module, that wraps up the whatwg-fetch.
// utils/fetch.js
// For browsers without Promise support
require('es6-promise').polyfill()
import 'whatwg-fetch'
// Can remove this if you would like
function checkStatus (response) {
console.log('response.status', response.status)
if (response.status >= 200 && response.status < 300) {
return response
}
const error = new Error(response.statusText)
error.response = response
throw error
}
export default function whatwgFetch (url, options) {
return fetch(url, options)
.then(checkStatus)
}
Import your fetch utility to use in your module
// myModule.js
import whatwgFetch from '../utils/fetch'
whatwgFetch('/users.html')
.then(function(response) {
return response.text()
}).then(function(body) {
document.body.innerHTML = body
})
Most helpful comment
It might be a little cumbersome but something like this could work:
Make a little fetch utility module, that wraps up the
whatwg-fetch.Import your fetch utility to use in your module