赞
踩
axios.defaults.timeout = 30000;在这里插入代码片 timeout时间单位是毫秒
//设置时间超时,timeout时间单位是毫秒
axios.post(url, postInfo,{timeout:300000})
.then((resp: any) => {
console.log(resp.data);
})
.catch((error: any) => {
console.error(error);
})
export interface AxiosRequestConfig {
url?: string;
method?: Method;
baseURL?: string;
transformRequest?: AxiosTransformer | AxiosTransformer[];
transformResponse?: AxiosTransformer | AxiosTransformer[];
headers?: any;
params?: any;
paramsSerializer?: (params: any) => string;
data?: any;
timeout?: number;
withCredentials?: boolean;
adapter?: AxiosAdapter;
auth?: AxiosBasicCredentials;
responseType?: ResponseType;
xsrfCookieName?: string;
xsrfHeaderName?: string;
onUploadProgress?: (progressEvent: any) => void;
onDownloadProgress?: (progressEvent: any) => void;
maxContentLength?: number;
validateStatus?: (status: number) => boolean;
maxRedirects?: number;
socketPath?: string | null;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig | false;
cancelToken?: CancelToken;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。