added user repo and group management working now
This commit is contained in:
@@ -7,6 +7,33 @@ import store from "@/store";
|
||||
const baseDomain = "http://localhost:5443";
|
||||
const API_URL = `${baseDomain}/api/v1`;
|
||||
|
||||
export default axios.create({
|
||||
const api = axios.create({
|
||||
baseURL: API_URL, headers: { Authorization: `Bearer ${store.state.access_token}` },
|
||||
});
|
||||
|
||||
api.interceptors.response.use(function (response) {
|
||||
return response;
|
||||
}, function (error) {
|
||||
if (401 === error.response.status) {
|
||||
Vue.swal({
|
||||
title: "Session Expired",
|
||||
text: "Your token/session has expired. Would you like to be redirected to the login page?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Yes",
|
||||
}).then( (result) => {
|
||||
if(result.value) {
|
||||
console.log("redirect to login!");
|
||||
window.location = '/login';
|
||||
} else {
|
||||
console.log("redirect to home!");
|
||||
window.location = '/';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
export default api;
|
||||
|
||||
Reference in New Issue
Block a user