2017-07-25 259 views
1

如何使用同構取我收到錯誤@類型/同構取沒有缺省出口獲取在打字稿

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() 
     ) 
    } 
} 

感謝您的幫助。

+0

您是否嘗試使用npm安裝它? npm install @ types/isomorphic-fetch 並導入取回,如下所示: import * as'fecth from'isomorphic-fetch「; –

回答

1

我能夠使其通過導入庫這樣的工作:

import 'isomorphic-fetch'; 

我不得不填充工具ES6,雖然之前的承諾。例如:

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