You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
629 B

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