diff --git a/packages/axios/src/index.ts b/packages/axios/src/index.ts index 0415bc3bd..c29d9d2bd 100644 --- a/packages/axios/src/index.ts +++ b/packages/axios/src/index.ts @@ -162,12 +162,12 @@ export function createFlatRequest, error: null }; } catch (error) { - return { data: null, error }; + return { data: null, error, response: (error as AxiosError).response }; } } as FlatRequestInstance; diff --git a/packages/axios/src/type.ts b/packages/axios/src/type.ts index e65e98497..644847ff8 100644 --- a/packages/axios/src/type.ts +++ b/packages/axios/src/type.ts @@ -92,18 +92,20 @@ export interface RequestInstance> extends RequestIns (config: CustomAxiosRequestConfig): Promise>; } -export type FlatResponseSuccessData = { +export type FlatResponseSuccessData = { data: T; error: null; + response: AxiosResponse; }; export type FlatResponseFailData = { data: null; error: AxiosError; + response: AxiosResponse; }; export type FlatResponseData = - | FlatResponseSuccessData + | FlatResponseSuccessData | FlatResponseFailData; export interface FlatRequestInstance, ResponseData = any> extends RequestInstanceCommon {