401 error
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import axios, { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { BASE_URL } from '@/helpers/constants';
|
||||
import { auth_service } from '@/services/auth';
|
||||
import axios, { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||
|
||||
const myAxios: AxiosInstance = axios.create({
|
||||
baseURL: BASE_URL,
|
||||
@@ -25,10 +26,11 @@ myAxios.interceptors.response.use(
|
||||
return response.data;
|
||||
},
|
||||
error => {
|
||||
// if (error.response?.status === 401) {
|
||||
// localStorage.removeItem('token');
|
||||
// window.location.href = '/';
|
||||
// }
|
||||
if (error.response?.status === 401) {
|
||||
// localStorage.removeItem('token');
|
||||
// window.location.href = '/';
|
||||
auth_service.logout();
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user