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
1 Answer
Reset to default 5I 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
版权声明:本文标题:javascript - How to use isomorphic-fetch in typescript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742235536a2438010.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论