0๐
As described by Delena Malan, thank you!;
let loading = function(callback) {
db.commit('setPageLoading', true);
new requests().concat([
'UserController@userDetails',
'SettingController@settings',
'ClientController@allClients',
'StatsController@statsUsage',
'UserController@paymentDetails'],
() => {
db.commit('setPageLoading', false);
/** everything's all gravy, `next()` should be called now! */
callback();
},
(error) => {
switch(error.response.status) {
case 401:
/** Put login box here, this will do for now **/
callback({ path: '/login' });
break;
case 498:
for(let i in error.response.data.errors) {
db.commit('setNotifications', []);
db.commit('addErrorNotification', error.response.data.errors[i][0]);
}
callback({ path: '/profile' });
break;
}
db.commit('setPageLoading', false);
});
};
Source:stackexchange.com