统一配置默认超时时间:

const httpAxios = axios.create();//创建实例
let Config = {
	TIMEOUT: 6000,//设置超时时间为6秒
	baseURL: {
		dev: window.BASEURL_01,
		prod: ''
	}
};
httpAxios.defaults.timeout = Config.TIMEOUT;

项目中普通api接口请求:

export function postRefresh(data) {
  return request({
    url: '/api/operation/payoutOrder/refresh',
    method: 'post',
    data
  })
}

重设超时时间的接口请求:

export function postRefresh(data) {
  return request({
    url: '/api/operation/payoutOrder/refresh',
    method: 'post',
    timeout: 100 * 1000,
    data
  })
}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐