Skip to content

Commit

Permalink
fix: 修复request请求自定义headers类型错误
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong321200875 committed Dec 19, 2023
1 parent 649fb17 commit bf2cd72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/axios/config.ts
@@ -1,4 +1,4 @@
import { AxiosResponse, AxiosRequestHeaders, InternalAxiosRequestConfig } from './types'
import { AxiosResponse, InternalAxiosRequestConfig } from './types'
import { ElMessage } from 'element-plus'
import qs from 'qs'
import { SUCCESS_CODE } from '@/constants'
Expand All @@ -7,7 +7,7 @@ import { useUserStoreWithOut } from '@/store/modules/user'
const defaultRequestInterceptors = (config: InternalAxiosRequestConfig) => {
if (
config.method === 'post' &&
(config.headers as AxiosRequestHeaders)['Content-Type'] === 'application/x-www-form-urlencoded'
config.headers['Content-Type'] === 'application/x-www-form-urlencoded'
) {
config.data = qs.stringify(config.data)
}
Expand Down
4 changes: 2 additions & 2 deletions types/global.d.ts
@@ -1,5 +1,5 @@
import type { CSSProperties } from 'vue'
import { AxiosRequestHeaders } from 'axios'
import { RawAxiosRequestHeaders } from 'axios'
declare global {
declare interface Fn<T = any> {
(...arg: T[]): T
Expand Down Expand Up @@ -40,7 +40,7 @@ declare global {
data?: any
url?: string
method?: AxiosMethod
headers?: AxiosRequestHeaders
headers?: RawAxiosRequestHeaders
responseType?: AxiosResponseType
}

Expand Down

0 comments on commit bf2cd72

Please sign in to comment.