0
votes

I am using vue js as frontend with laravel. I am using laravel passport for auth, now i wants to show some error message once received 401 unauthentic error message that mostly occurs when my token expired. so to do this i am using axios interceptors my code is like

axios.interceptors.response.use(function (response) { return response }, function (error) { // const { config, response: { status } } = error const { config, response } = error const originalRequest = config if (response && response.status === 401) { //notication or redirection this.$vs.notify({ title: 'Error', text: response.data['message'], iconPack: 'feather', icon: 'icon-check-circle', color: 'danger' }) } return Promise.reject(error) })

Now Question is that where i put this code in vue js so that it call after every request & so an error message shown & redirect to login once get 401 unauthorized..

Any Suggestion from anyone.

Thanks in advance!!

1

1 Answers

0
votes