Last active
October 7, 2023 01:44
-
-
Save nemanja947/a71018e659f7d5255ea43c304f8ee108 to your computer and use it in GitHub Desktop.
NProgress implementation with Axios
This file contains hidden or 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
Thank you!