inital commit

This commit is contained in:
Torsten Schulz
2024-06-15 23:01:46 +02:00
parent 1b7fefe381
commit 61653ff407
105 changed files with 7805 additions and 524 deletions

33
src/axios.js Normal file
View File

@@ -0,0 +1,33 @@
import axios from 'axios';
import store from './store';
import router from './router';
axios.defaults.baseURL = 'http://localhost:3000/api';
axios.interceptors.request.use(
config => {
const token = store.state.token;
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
},
error => {
return Promise.reject(error);
}
);
axios.interceptors.response.use(
response => {
return response;
},
error => {
if (error.response && error.response.status === 401) {
store.commit('logout');
router.push('/');
}
return Promise.reject(error);
}
);
export default axios;