mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-08 09:24:59 +01:00
Add response interceptor to axios to handle errors
This commit is contained in:
parent
d9b8419ac9
commit
2fc1ec4020
16
resources/js/packages/axios.js
vendored
16
resources/js/packages/axios.js
vendored
@ -13,3 +13,19 @@ axios.interceptors.request.use(request => {
|
||||
|
||||
return request
|
||||
})
|
||||
|
||||
// Response interceptor
|
||||
axios.interceptors.response.use(response => response, error => {
|
||||
|
||||
const { status } = error.response
|
||||
|
||||
if (status >= 500) {
|
||||
// do something ?
|
||||
}
|
||||
|
||||
if (status === 404) {
|
||||
router.push({name: '404', params: { err : error.response.data.error }})
|
||||
}
|
||||
|
||||
return Promise.reject(error)
|
||||
})
|
Loading…
Reference in New Issue
Block a user