|
|
- import axios from 'axios'
- import router from '@/router'
-
- import admin from '@/store/admin/index.js'
-
- const instance = axios.create({
- baseURL: "http://localhost:8080/api/v1/",
- headers: {
- "Content-Type": "application/json",
- },
- });
-
- instance.interceptors.response.use(
- function (response) {
- return response;
- },
-
- function (error) {
- if (error.response.status === 401) {
- admin.dispatch('setUser', null)
- router.push({ name: 'AdminLogin', params: { unauthorized: true } })
- return
- }
-
- return Promise.reject(error);
- }
- );
-
- export default instance
|