(资料图片)
@toc
import axios from "axios"import bus from "@/utils/bus"import {Message} from "element-ui"const service = axios.create({ baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url // baseURL: "/api", // url = base url + request url timeout: 100000, // request timeout})service.interceptors.request.use( config => { let currentUser = JSON.parse(sessionStorage.getItem("UserInfo")) if (currentUser && currentUser.token) { config.headers["Authorization"] = "token " + currentUser.token } return config }, error => { console.log(error) return Promise.reject(error) })// response interceptorservice.interceptors.response.use( response => { return response }, error => { const res = error.response.data const status = error.response.status if (status >= 500) { Message.error("服务繁忙请稍后再试") } else if (status >= 400) { if (res.status === 401) { Message.warning("您的账号登录已失效, 请重新登录") bus.$emit("logout") } else { Message.error("未知错误") console.error(error) } } return Promise.resolve(error) })export default service
// 卡片管理模块import request from "@/utils/request"// getexport function getList(params) { return request({ url: "/", method: "get", params })}// POSTexport function postList(data) { return request({ url: "/", method: "POST", responseType: "arraybuffer", data })}
//引入import { getList, postList} from "@/api/comparison.js";//使用 getList().then((res) => { });
免责声明:以上内容为本网站转自其它媒体,相关信息仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同其观点或证实其内容的真实性。如稿件版权单位或个人不想在本网发布,可与本网联系,本网视情况可立即将其撤除。