mirror of
https://github.com/PlayEdu/backend
synced 2026-03-09 17:00:35 +08:00
http封装
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import axios from "axios";
|
||||
|
||||
axios.defaults.timeout = 10000;
|
||||
axios.defaults.headers.Authorization = "Bearer ";
|
||||
axios.defaults.headers.common["meedu-platform"] = "backend";
|
||||
axios.defaults.baseURL = "https://dev-local.meedu.vip/";
|
||||
|
||||
// 响应拦截器
|
||||
axios.interceptors.response.use(
|
||||
(res) => res.data, // 拦截到响应对象,将响应对象的 data 属性返回给调用的地方
|
||||
(err) => Promise.reject(err)
|
||||
);
|
||||
11
src/utils/index.ts
Normal file
11
src/utils/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function getToken(): string {
|
||||
return window.localStorage.getItem("playedu-backend-token") || "";
|
||||
}
|
||||
|
||||
export function setToken(token: string) {
|
||||
window.localStorage.setItem("playedu-backend-token", token);
|
||||
}
|
||||
|
||||
export function clearToken() {
|
||||
window.localStorage.removeItem("playedu-backend-token");
|
||||
}
|
||||
Reference in New Issue
Block a user