We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 67bfca5 commit f90345dCopy full SHA for f90345d
vue/src/axios.js
@@ -3,6 +3,7 @@
3
*/
4
import axios from "axios";
5
import store from "./store";
6
+import {useRouter} from 'vue-router'
7
8
const axiosClient = axios.create({
9
baseURL: `${import.meta.env.VITE_API_BASE_URL}/api`
@@ -13,4 +14,15 @@ axiosClient.interceptors.request.use(config => {
13
14
return config;
15
})
16
17
+axiosClient.interceptors.response.use(response => {
18
+ return response;
19
+}, error => {
20
+ if (error.response.status === 401) {
21
+ const router = useRouter();
22
+ sessionStorage.removeItem('TOKEN')
23
+ router.push({name: 'Login'})
24
+ }
25
+ return error;
26
+})
27
+
28
export default axiosClient;
0 commit comments