'Get request method name in axios response interceptor
I am using axios response interceptor and wish to get request method name (GET/POST/PATCH etc) whenever there is an error in HTTP api.
axios.interceptors.response.use(error => {
let method = ''; // How to get which request method was used?
if (method == 'GET') {
// do something
} else if (method == 'POST') {
// do something else
}
return Promise.reject(error)
});
Any idea how to get the request method name inside this callback?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
