axios-miniprogram/src/defaults.ts

82 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-07-27 11:40:32 +08:00
import { AxiosRequestConfig } from './types';
import adaptive from './adaptive';
const defaults: AxiosRequestConfig = {
/**
*
*/
adapter: adaptive(),
/**
*
*/
method: 'get',
/**
*
*/
headers: {
common: {
Accept: 'application/json, test/plain, */*',
},
options: {},
get: {},
head: {},
post: {
'Context-Type': 'application/x-www-form-urlencoded; charset=utf-8',
},
put: {
'Context-Type': 'application/x-www-form-urlencoded; charset=utf-8',
},
delete: {},
trace: {},
connect: {},
},
/**
*
*
* @param status
*/
validateStatus: function validateStatus(status: number): boolean {
return status >= 200 && status < 300;
},
/**
*
*/
timeout: 10000,
/**
*
*/
dataType: 'json',
/**
*
*/
responseType: 'text',
/**
* http2
*/
enableHttp2: false,
/**
* quic
*/
enableQuic: false,
/**
* cache
*/
enableCache: false,
/**
* ssl
*/
sslVerify: true,
};
export default defaults;