frontend converted to ts
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
import axios from 'axios';
|
||||
import store from '../store';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: '/api',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
api.interceptors.response.use(
|
||||
(res) => res,
|
||||
(err) => {
|
||||
if (err.response.status === 401) {
|
||||
store.dispatch({ type: 'auth/logOut' });
|
||||
}
|
||||
return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
|
||||
export default api;
|
||||
Reference in New Issue
Block a user