1、http 请求拦截器

axios.interceptors.request.use(function(config){
//在发送请求之前做些什么
return config
}),
function(error){
//请求错误做些什么
return Promise.reject(error);
}
//或者:
axios.insterceptors.request.use(config=>{
//在发送请求之前做些什么
return config
}),
error=> {
//请求错误做些什么
return Promise.reject(error);
}

 

2、http 返回拦截器

 

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
// 对响应数据做点什么
return response;
}, 
function (error) {
// 对响应错误做点什么
return Promise.reject(error);
});

 

相关文章:

  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-08-08
相关资源
相似解决方案