axios.interceptors.response.use(
response => response,
function (error) {
let response = error.response,
status = response.status
if (status === 404) {
router.push({name: 'NotFound'})
return
}
)
myComponent.get('/search', {
params: {
key: value
},
ignore404: true
})
axios.interceptors.response.use(
response => response,
error => {
const {
response: {
status
},
config: {
ignore404
}
} = error
if (status === 404) {
if (!ignore404) {
router.push({name: 'NotFound'})
}
return
}
}
)