Reputation: 23
I want to intercept all ajax requests with a status code of -1 in all response and redirect it to the login screen. But I have been unable to monitor it. What should I do? Thank you.
My method:
app.js
Framework7.Dom7(document).on('ajaxComplete', function(e){
console.log('Monitored')
})
Upvotes: 0
Views: 117
Reputation: 2993
Try this.
Create a new file name interceptors.js
interceptors.js
import axios from 'axios';
import Vue from 'vue'
export default function setup() {
axios.interceptors.response.use(function (config) {
// Do something before the request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
}
then in your app.js
import the interceptors.js
app.js
import interceptorsSetup from './interceptors';
interceptorsSetup()
Upvotes: 1