mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-24 02:00:22 +08:00
feat(axios): Do you want to return the original response header? For example, use this property when you need to get the response header
This commit is contained in:
parent
2f8b2183ec
commit
56d8af147e
@ -35,7 +35,11 @@ const transform: AxiosTransform = {
|
||||
*/
|
||||
transformRequestHook: (res: AxiosResponse<Result>, options: RequestOptions) => {
|
||||
const { t } = useI18n();
|
||||
const { isTransformRequestResult } = options;
|
||||
const { isTransformRequestResult, isReturnNativeResponse } = options;
|
||||
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
||||
if (isReturnNativeResponse) {
|
||||
return res;
|
||||
}
|
||||
// 不进行任何处理,直接返回
|
||||
// 用于页面代码可能需要直接获取code,data,message这些信息时开启
|
||||
if (!isTransformRequestResult) {
|
||||
@ -192,6 +196,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
||||
requestOptions: {
|
||||
// 默认将prefix 添加到url
|
||||
joinPrefix: true,
|
||||
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
||||
isReturnNativeResponse: false,
|
||||
// 需要对返回数据进行处理
|
||||
isTransformRequestResult: true,
|
||||
// post请求的时候添加参数到url
|
||||
|
@ -7,6 +7,8 @@ export interface RequestOptions {
|
||||
formatDate?: boolean;
|
||||
// Whether to process the request result
|
||||
isTransformRequestResult?: boolean;
|
||||
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
||||
isReturnNativeResponse?: boolean;
|
||||
// Whether to join url
|
||||
joinPrefix?: boolean;
|
||||
// Interface address, use the default apiUrl if you leave it blank
|
||||
|
Loading…
Reference in New Issue
Block a user