import axios from 'axios'
import router from '../router'
import { ElNotification } from 'element-plus'
const myaxios = new axios.create({})
myaxios.interceptors.request.use((config) => {
config.baseURL = "http://api_devs.wanxikeji.cn";
config.timeout = 5000;
return config
})
myaxios.interceptors.response.use(res => {
if (res.data.code > 2999) {
localStorage.removeItem('token');
ElNotification({
title: '发生错误',
message: '登录失效,即将返回登录页面',
type: 'error',
})
setTimeout(() => {
router.push('/')
}, 2000);
} else {
}
return res
})
export default myaxios
axios
最新推荐文章于 2024-10-31 15:49:24 发布