mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-27 08:24:39 +00:00
23 lines
752 B
JavaScript
Vendored
23 lines
752 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')){
|
|
dispatch('userAuthentication', {access_token: '', redirect_url: '/'});
|
|
}
|
|
|
|
return response;
|
|
|
|
})
|
|
}
|
|
}
|
|
} |