Commit 4f35b95b6b7a0234df095533a7ee38a6396350f3
Committed by
GitHub
1 parent
46e28f02
fix: Multiple calls to createAxios function transform parameters are overwritten…
… by other calls (#1474)
Showing
1 changed file
with
2 additions
and
1 deletions
src/utils/http/axios/index.ts
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | // The axios configuration can be changed according to the project, just change the file, other files can be left unchanged | 2 | // The axios configuration can be changed according to the project, just change the file, other files can be left unchanged |
3 | 3 | ||
4 | import type { AxiosResponse } from 'axios'; | 4 | import type { AxiosResponse } from 'axios'; |
5 | +import { clone } from 'lodash-es'; | ||
5 | import type { RequestOptions, Result } from '/#/axios'; | 6 | import type { RequestOptions, Result } from '/#/axios'; |
6 | import type { AxiosTransform, CreateAxiosOptions } from './axiosTransform'; | 7 | import type { AxiosTransform, CreateAxiosOptions } from './axiosTransform'; |
7 | import { VAxios } from './Axios'; | 8 | import { VAxios } from './Axios'; |
@@ -208,7 +209,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) { | @@ -208,7 +209,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) { | ||
208 | // 如果是form-data格式 | 209 | // 如果是form-data格式 |
209 | // headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED }, | 210 | // headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED }, |
210 | // 数据处理方式 | 211 | // 数据处理方式 |
211 | - transform, | 212 | + transform: clone(transform), |
212 | // 配置项,下面的选项都可以在独立的接口请求中覆盖 | 213 | // 配置项,下面的选项都可以在独立的接口请求中覆盖 |
213 | requestOptions: { | 214 | requestOptions: { |
214 | // 默认将prefix 添加到url | 215 | // 默认将prefix 添加到url |