如何解决在成功和错误情况下如何使用Inteceptor
axios.interceptors.response.use(function (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);
});
axios.interceptors.request.use(function (config) {
// Do something before request is sent
return config;
},function (error) {
// Do something with request error
return Promise.reject(error);
});
有没有办法在成功代码和错误代码块中同时写代码并有效地使用代码,就像Promise.finally一样?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。