1 | export interface AxiosTransformer {
|
2 | (data: any, headers?: any): any;
|
3 | }
|
4 |
|
5 | export interface AxiosAdapter {
|
6 | (config: AxiosRequestConfig): AxiosPromise<any>;
|
7 | }
|
8 |
|
9 | export interface AxiosBasicCredentials {
|
10 | username: string;
|
11 | password: string;
|
12 | }
|
13 |
|
14 | export interface AxiosProxyConfig {
|
15 | host: string;
|
16 | port: number;
|
17 | auth?: {
|
18 | username: string;
|
19 | password:string;
|
20 | };
|
21 | protocol?: string;
|
22 | }
|
23 |
|
24 | export type Method =
|
25 | | 'get' | 'GET'
|
26 | | 'delete' | 'DELETE'
|
27 | | 'head' | 'HEAD'
|
28 | | 'options' | 'OPTIONS'
|
29 | | 'post' | 'POST'
|
30 | | 'put' | 'PUT'
|
31 | | 'patch' | 'PATCH'
|
32 | | 'purge' | 'PURGE'
|
33 | | 'link' | 'LINK'
|
34 | | 'unlink' | 'UNLINK'
|
35 |
|
36 | export type ResponseType =
|
37 | | 'arraybuffer'
|
38 | | 'blob'
|
39 | | 'document'
|
40 | | 'json'
|
41 | | 'text'
|
42 | | 'stream'
|
43 |
|
44 | export interface TransitionalOptions{
|
45 | silentJSONParsing: boolean;
|
46 | forcedJSONParsing: boolean;
|
47 | clarifyTimeoutError: boolean;
|
48 | }
|
49 |
|
50 | export interface AxiosRequestConfig {
|
51 | url?: string;
|
52 | method?: Method;
|
53 | baseURL?: string;
|
54 | transformRequest?: AxiosTransformer | AxiosTransformer[];
|
55 | transformResponse?: AxiosTransformer | AxiosTransformer[];
|
56 | headers?: any;
|
57 | params?: any;
|
58 | paramsSerializer?: (params: any) => string;
|
59 | data?: any;
|
60 | timeout?: number;
|
61 | timeoutErrorMessage?: string;
|
62 | withCredentials?: boolean;
|
63 | adapter?: AxiosAdapter;
|
64 | auth?: AxiosBasicCredentials;
|
65 | responseType?: ResponseType;
|
66 | xsrfCookieName?: string;
|
67 | xsrfHeaderName?: string;
|
68 | onUploadProgress?: (progressEvent: any) => void;
|
69 | onDownloadProgress?: (progressEvent: any) => void;
|
70 | maxContentLength?: number;
|
71 | validateStatus?: ((status: number) => boolean) | null;
|
72 | maxBodyLength?: number;
|
73 | maxRedirects?: number;
|
74 | socketPath?: string | null;
|
75 | httpAgent?: any;
|
76 | httpsAgent?: any;
|
77 | proxy?: AxiosProxyConfig | false;
|
78 | cancelToken?: CancelToken;
|
79 | decompress?: boolean;
|
80 | transitional?: TransitionalOptions
|
81 | }
|
82 |
|
83 | export interface AxiosResponse<T = any> {
|
84 | data: T;
|
85 | status: number;
|
86 | statusText: string;
|
87 | headers: any;
|
88 | config: AxiosRequestConfig;
|
89 | request?: any;
|
90 | }
|
91 |
|
92 | export interface AxiosError<T = any> extends Error {
|
93 | config: AxiosRequestConfig;
|
94 | code?: string;
|
95 | request?: any;
|
96 | response?: AxiosResponse<T>;
|
97 | isAxiosError: boolean;
|
98 | toJSON: () => object;
|
99 | }
|
100 |
|
101 | export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
|
102 | }
|
103 |
|
104 | export interface CancelStatic {
|
105 | new (message?: string): Cancel;
|
106 | }
|
107 |
|
108 | export interface Cancel {
|
109 | message: string;
|
110 | }
|
111 |
|
112 | export interface Canceler {
|
113 | (message?: string): void;
|
114 | }
|
115 |
|
116 | export interface CancelTokenStatic {
|
117 | new (executor: (cancel: Canceler) => void): CancelToken;
|
118 | source(): CancelTokenSource;
|
119 | }
|
120 |
|
121 | export interface CancelToken {
|
122 | promise: Promise<Cancel>;
|
123 | reason?: Cancel;
|
124 | throwIfRequested(): void;
|
125 | }
|
126 |
|
127 | export interface CancelTokenSource {
|
128 | token: CancelToken;
|
129 | cancel: Canceler;
|
130 | }
|
131 |
|
132 | export interface AxiosInterceptorManager<V> {
|
133 | use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number;
|
134 | eject(id: number): void;
|
135 | }
|
136 |
|
137 | export interface AxiosInstance {
|
138 | (config: AxiosRequestConfig): AxiosPromise;
|
139 | (url: string, config?: AxiosRequestConfig): AxiosPromise;
|
140 | defaults: AxiosRequestConfig;
|
141 | interceptors: {
|
142 | request: AxiosInterceptorManager<AxiosRequestConfig>;
|
143 | response: AxiosInterceptorManager<AxiosResponse>;
|
144 | };
|
145 | getUri(config?: AxiosRequestConfig): string;
|
146 | request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
|
147 | get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
148 | delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
149 | head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
150 | options<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
151 | post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
152 | put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
153 | patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
154 | }
|
155 |
|
156 | export interface AxiosStatic extends AxiosInstance {
|
157 | create(config?: AxiosRequestConfig): AxiosInstance;
|
158 | Cancel: CancelStatic;
|
159 | CancelToken: CancelTokenStatic;
|
160 | isCancel(value: any): boolean;
|
161 | all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
|
162 | spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
163 | isAxiosError(payload: any): payload is AxiosError;
|
164 | }
|
165 |
|
166 | declare const axios: AxiosStatic;
|
167 |
|
168 | export default axios;
|