mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
23 lines
920 B
JavaScript
Vendored
23 lines
920 B
JavaScript
Vendored
export default {
|
|
actions: {
|
|
crudRequest({getters, dispatch}, {endpoint, method, parameters}){
|
|
return fetch(endpoint, {
|
|
method: method,
|
|
responseType: 'json',
|
|
body: parameters ? JSON.stringify(parameters):null,
|
|
headers: {
|
|
'content-type': 'application/json',
|
|
'Authorization': 'Bearer '+getters.getAccessToken
|
|
}
|
|
}).then(response => {
|
|
if(response.status === 401 && window.location.href !== route('login') && window.location.href.indexOf(route('last_mile_delivery.login')) <= -1){
|
|
dispatch('userAuthentication', {access_token: '', redirect_url: [7, 8].includes(getters.getCompanyModuleType) ? route('last_mile_delivery.login') : route('login')});
|
|
}
|
|
|
|
return response;
|
|
|
|
})
|
|
}
|
|
}
|
|
}
|