// Add a request interceptor添加请求拦截器
axios.interceptors.request.use(config => {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
// Add a response interceptor添加响应拦截器
axios.interceptors.response.use(response => {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response;
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
});
Vue-Axios请求拦截器和响应拦截器
猜你喜欢
转载自blog.csdn.net/gandongusa/article/details/122821255
今日推荐
周排行