提交 215f5f54 authored 作者: vipcxj's avatar vipcxj

add: 支持fetch的超时配置

上级 a9926bca
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
"react-native": "^0.49.3", "react-native": "^0.49.3",
"react-native-code-push": "^5.1.3-beta", "react-native-code-push": "^5.1.3-beta",
"react-native-device-info": "^0.12.1", "react-native-device-info": "^0.12.1",
"react-native-fetch-polyfill": "^1.1.2",
"react-navigation": "^1.0.0-beta.14", "react-navigation": "^1.0.0-beta.14",
"react-redux": "^5.0.6", "react-redux": "^5.0.6",
"redux-persist": "^4.10.1" "redux-persist": "^4.10.1"
......
...@@ -6,6 +6,7 @@ import { getToken } from './auth'; ...@@ -6,6 +6,7 @@ import { getToken } from './auth';
import { checkStatus, normParams, parseObject } from './http-helper'; import { checkStatus, normParams, parseObject } from './http-helper';
const defaultOptions = { const defaultOptions = {
timeout: 30 * 1000,
headers: { Accept: 'application/json' }, headers: { Accept: 'application/json' },
}; };
......
/* eslint-disable prefer-destructuring */ // eslint-disable-next-line global-require
export const fetch = require('react-native-fetch-polyfill');
// noinspection JSUnresolvedVariable
export const fetch = global.fetch;
...@@ -7,6 +7,7 @@ import { getToken } from './auth'; ...@@ -7,6 +7,7 @@ import { getToken } from './auth';
import { errors } from './error'; import { errors } from './error';
const defaultOptions = { const defaultOptions = {
timeout: 30 * 1000,
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
}, },
......
...@@ -6,6 +6,7 @@ import { errors } from './error'; ...@@ -6,6 +6,7 @@ import { errors } from './error';
import { checkStatus, normParams, parseObject } from './http-helper'; import { checkStatus, normParams, parseObject } from './http-helper';
const defaultOptions = { const defaultOptions = {
timeout: 30 * 1000,
headers: { Accept: 'application/json' }, headers: { Accept: 'application/json' },
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论