diff --git a/packages/axios/src/index.ts b/packages/axios/src/index.ts index c9359c0..7cd9f02 100644 --- a/packages/axios/src/index.ts +++ b/packages/axios/src/index.ts @@ -162,13 +162,13 @@ 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 ed8e046..0256969 100644 --- a/packages/axios/src/type.ts +++ b/packages/axios/src/type.ts @@ -92,18 +92,19 @@ export interface RequestInstance> extends RequestIns (config: CustomAxiosRequestConfig): Promise> } -export interface FlatResponseSuccessData { +export type FlatResponseSuccessData = { data: T error: null + response: AxiosResponse } - export interface FlatResponseFailData { data: null error: AxiosError + response: AxiosResponse } export type FlatResponseData = - | FlatResponseSuccessData + | FlatResponseSuccessData | FlatResponseFailData export interface FlatRequestInstance, ResponseData = any> extends RequestInstanceCommon {