Last active
April 1, 2020 07:21
-
-
Save kianaditya/d12bdd0f373e92df706f86098f595539 to your computer and use it in GitHub Desktop.
Axios reponse interceptor example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http.interceptors.response.use( | |
response => { | |
return response; | |
}, | |
error => { | |
if (error.response) { | |
switch (error.response.status) { | |
case 500: | |
return (document.location.href = | |
process.env.REACT_APP_CLIENT_URL + "/500"); | |
case 404: | |
return (document.location.href = | |
process.env.REACT_APP_CLIENT_URL + "/404"); | |
default: | |
return Promise.reject(error); | |
} | |
} | |
return Promise.reject(error); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment