-
-
Save AleksejDix/52e7eab445c18d33e659945bc8c19f96 to your computer and use it in GitHub Desktop.
NProgress implementation with Axios
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
// Add a request interceptor | |
axios.interceptors.request.use(function (config) { | |
// Do something before request is sent | |
NProgress.start(); | |
return config; | |
}, function (error) { | |
// Do something with request error | |
console.error(error) | |
return Promise.reject(error); | |
}); | |
// Add a response interceptor | |
axios.interceptors.response.use(function (response) { | |
// Do something with response data | |
NProgress.done(); | |
return response; | |
}, function (error) { | |
// Do something with response error | |
console.error(error) | |
return Promise.reject(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment