mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Distinguish request and response data types (#4116)
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Vendored
+15
-15
@@ -47,7 +47,7 @@ export interface TransitionalOptions{
|
|||||||
clarifyTimeoutError: boolean;
|
clarifyTimeoutError: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosRequestConfig<T = any> {
|
export interface AxiosRequestConfig<D = any> {
|
||||||
url?: string;
|
url?: string;
|
||||||
method?: Method;
|
method?: Method;
|
||||||
baseURL?: string;
|
baseURL?: string;
|
||||||
@@ -56,7 +56,7 @@ export interface AxiosRequestConfig<T = any> {
|
|||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
params?: any;
|
params?: any;
|
||||||
paramsSerializer?: (params: any) => string;
|
paramsSerializer?: (params: any) => string;
|
||||||
data?: T;
|
data?: D;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
timeoutErrorMessage?: string;
|
timeoutErrorMessage?: string;
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
@@ -81,20 +81,20 @@ export interface AxiosRequestConfig<T = any> {
|
|||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosResponse<T = never> {
|
export interface AxiosResponse<T = never, D = any> {
|
||||||
data: T;
|
data: T;
|
||||||
status: number;
|
status: number;
|
||||||
statusText: string;
|
statusText: string;
|
||||||
headers: Record<string, string>;
|
headers: Record<string, string>;
|
||||||
config: AxiosRequestConfig<T>;
|
config: AxiosRequestConfig<D>;
|
||||||
request?: any;
|
request?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosError<T = never> extends Error {
|
export interface AxiosError<T = never, D = any> extends Error {
|
||||||
config: AxiosRequestConfig;
|
config: AxiosRequestConfig<D>;
|
||||||
code?: string;
|
code?: string;
|
||||||
request?: any;
|
request?: any;
|
||||||
response?: AxiosResponse<T>;
|
response?: AxiosResponse<T, D>;
|
||||||
isAxiosError: boolean;
|
isAxiosError: boolean;
|
||||||
toJSON: () => object;
|
toJSON: () => object;
|
||||||
}
|
}
|
||||||
@@ -143,14 +143,14 @@ export class Axios {
|
|||||||
response: AxiosInterceptorManager<AxiosResponse>;
|
response: AxiosInterceptorManager<AxiosResponse>;
|
||||||
};
|
};
|
||||||
getUri(config?: AxiosRequestConfig): string;
|
getUri(config?: AxiosRequestConfig): string;
|
||||||
request<T = never, R = AxiosResponse<T>> (config: AxiosRequestConfig<T>): Promise<R>;
|
request<T = never, R = AxiosResponse<T>, D = any> (config: AxiosRequestConfig<D>): Promise<R>;
|
||||||
get<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>;
|
get<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
delete<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>;
|
delete<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
head<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>;
|
head<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
options<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>;
|
options<T = never, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
post<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>;
|
post<T = never, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
put<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>;
|
put<T = never, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
patch<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>;
|
patch<T = never, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInstance extends Axios {
|
export interface AxiosInstance extends Axios {
|
||||||
|
|||||||
Reference in New Issue
Block a user