项目微调
优化封装的Axios
This commit is contained in:
@@ -18,13 +18,15 @@ const config = {
|
|||||||
// 设置超时时间
|
// 设置超时时间
|
||||||
timeout: ResultEnum.TIMEOUT as number,
|
timeout: ResultEnum.TIMEOUT as number,
|
||||||
// 跨域时候允许携带凭证
|
// 跨域时候允许携带凭证
|
||||||
withCredentials: true
|
withCredentials: true,
|
||||||
|
// post请求指定数据类型以及编码
|
||||||
|
headers: { 'Content-Type': 'application/json;charset=utf-8' }
|
||||||
};
|
};
|
||||||
|
|
||||||
class RequestHttp {
|
class RequestHttp {
|
||||||
service: AxiosInstance;
|
service: AxiosInstance;
|
||||||
public constructor(config: AxiosRequestConfig) {
|
public constructor(config: AxiosRequestConfig) {
|
||||||
// instantiation
|
// 创建实例
|
||||||
this.service = axios.create(config);
|
this.service = axios.create(config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user