我正在努力理解 axios 拦截器是如何使用的。在我发现的每个示例中都使用了这样的代码
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.patch(addr, data, {
headers: this.headers,
httpsAgent: this.agent,
})
.then(res => {
resolve(true)
})
.catch(error => {
resolve(false);
})