axios二次封装

1. axios文档:axios中文网|axios API 中文文档 | axios
2. 封装:
/**
* axios二次封装
*/

import axios from 'axios';
import config from '../config/index';
import { ElMessage } from 'element-plus';
import router from '../router/index';

const TOKEN_INVALID = 'Token认证失败,请重新登录';
const NEWWORK_ERROR = '网络请求异常,请稍后再试';

const server = axios.create({
baseURL: config.baseApi,
timeout: 8000
})

server.interceptors.request.use(req => {
// 请求拦截,拼接token
if (!req.headers.Authorization) {
r

axios二次封装最先出现在Python成神之路

版权声明:
作者:ht
链接:https://www.techfm.club/p/25871.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>