更新 src/api/axios.ts
This commit is contained in:
parent
636af8d020
commit
63f862f1cd
@ -1,4 +1,4 @@
|
||||
import axios, { AxiosResponse, AxiosRequestConfig, Axios, AxiosError } from 'axios'
|
||||
import axios, { AxiosResponse, AxiosRequestConfig, Axios, AxiosError, InternalAxiosRequestConfig } from 'axios'
|
||||
import { RequestHttpHeaderEnum, ResultEnum, ModuleTypeEnum } from '@/enums/httpEnum'
|
||||
import { PageEnum, ErrorPageNameMap } from '@/enums/pageEnum'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
@ -24,7 +24,7 @@ const axiosInstance = axios.create({
|
||||
}) as unknown as MyRequestInstance
|
||||
|
||||
axiosInstance.interceptors.request.use(
|
||||
(config: AxiosRequestConfig) => {
|
||||
(config: InternalAxiosRequestConfig) => {
|
||||
// 白名单校验
|
||||
if (includes(fetchAllowList, config.url)) return config
|
||||
// 获取 token
|
||||
@ -51,9 +51,6 @@ axiosInstance.interceptors.response.use(
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
const { code } = res.data as { code: number }
|
||||
|
||||
const responseData = res as AxiosResponse<any>
|
||||
const { code } = responseData.data as { code: number }
|
||||
|
||||
if (code === undefined || code === null) return Promise.resolve(res.data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user