hi , in my framework when you call to a route which requires use login … if user is not logged and request is not ajax user gets redirect to login page … but if request is ajax … it returns this json string {error:Unauthenticated}
also in the header it returns
Status code:401 Unauthorized
how can i handle this in all my routes so if a page route returns this json object {error:Unauthenticated}
i can redirect user to login route ?
i tried to catch it in route events
var f7app = new Framework7({
root: '#app',
name: 'My App',
id: 'com.myapp.test',
on: {
pageMounted: function (e, page) {
console.log('pageMounted');
},
pageAfterIn: function (e, page) {
console.log('pageAfterIn');
},
pageInit: function (e, page) {
console.log('pageInit');
} ,
pageBeforeRemove: function (e, page) {
console.log('pageBeforeRemove');
}
} ,
routes:ROUTES
});
but all events fire after ajax call to page is done successfully … is there an event for before ajax call and after ajax call failed ?