admin管理员组

文章数量:1328018

I am getting error @types/isomorphic-fetch has no default export fetch

import fetch from 'isomorphic-fetch';

export const AUTH_FAIL = "AUTH_FAIL"
export const ERROR_FETCH = "EROR_FETCH";
export const SUCCESS_FETCH = "SUCESS_FETCH";
export const START_FETCH = "START_FETCH";

export function start_fetch(){ 
    return function(dispatch: any){
        return fetch("http://localhost:8000/api/data")
        .then(
            response => response.json()
        )
    }
}

thanks for your help.

I am getting error @types/isomorphic-fetch has no default export fetch

import fetch from 'isomorphic-fetch';

export const AUTH_FAIL = "AUTH_FAIL"
export const ERROR_FETCH = "EROR_FETCH";
export const SUCCESS_FETCH = "SUCESS_FETCH";
export const START_FETCH = "START_FETCH";

export function start_fetch(){ 
    return function(dispatch: any){
        return fetch("http://localhost:8000/api/data")
        .then(
            response => response.json()
        )
    }
}

thanks for your help.

Share Improve this question asked Jul 25, 2017 at 3:50 Krishna SatyaKrishna Satya 8752 gold badges10 silver badges21 bronze badges 1
  • 1 did you try to install it using npm ? npm install @types/isomorphic-fetch and import fetch like below: import * as fecth from 'isomorphic-fetch"; – DirtyMind Commented Dec 7, 2017 at 6:40
Add a ment  | 

1 Answer 1

Reset to default 5

I was able to make it work by importing the library like this:

import 'isomorphic-fetch';

I had to polyfill ES6 Promises before that though. For example:

import * as e6p from "es6-promise";
(e6p as any).polyfill();

本文标签: javascriptHow to use isomorphicfetch in typescriptStack Overflow