axios 1.1.3 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +298 -75
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +61 -25
- package/dist/axios.js +886 -582
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +3189 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +886 -625
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +972 -554
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +528 -0
- package/index.d.ts +116 -56
- package/index.js +12 -3
- package/lib/adapters/adapters.js +59 -0
- package/lib/adapters/http.js +87 -34
- package/lib/adapters/xhr.js +7 -4
- package/lib/axios.js +13 -3
- package/lib/core/Axios.js +10 -8
- package/lib/core/AxiosError.js +1 -1
- package/lib/core/AxiosHeaders.js +102 -80
- package/lib/core/dispatchRequest.js +7 -2
- package/lib/core/mergeConfig.js +50 -46
- package/lib/defaults/index.js +2 -21
- package/lib/env/classes/FormData.js +2 -2
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +71 -0
- package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/lib/helpers/formDataToStream.js +111 -0
- package/lib/helpers/readBlob.js +15 -0
- package/lib/helpers/speedometer.js +1 -1
- package/lib/helpers/toFormData.js +5 -15
- package/lib/platform/browser/classes/FormData.js +1 -1
- package/lib/platform/browser/index.js +20 -0
- package/lib/utils.js +107 -9
- package/package.json +86 -14
- package/bin/ssl_hotfix.js +0 -22
- package/gulpfile.js +0 -88
- package/karma.conf.cjs +0 -250
- package/lib/adapters/index.js +0 -33
- package/rollup.config.js +0 -90
- package/tsconfig.json +0 -14
- package/tslint.json +0 -6
package/index.d.cts
ADDED
@@ -0,0 +1,528 @@
|
|
1
|
+
type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
2
|
+
|
3
|
+
interface RawAxiosHeaders {
|
4
|
+
[key: string]: AxiosHeaderValue;
|
5
|
+
}
|
6
|
+
|
7
|
+
type MethodsHeaders = Partial<{
|
8
|
+
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
|
9
|
+
} & {common: AxiosHeaders}>;
|
10
|
+
|
11
|
+
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
|
12
|
+
|
13
|
+
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent'| 'Content-Encoding' | 'Authorization';
|
14
|
+
|
15
|
+
type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
|
16
|
+
|
17
|
+
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';
|
18
|
+
|
19
|
+
declare class AxiosHeaders {
|
20
|
+
constructor(
|
21
|
+
headers?: RawAxiosHeaders | AxiosHeaders
|
22
|
+
);
|
23
|
+
|
24
|
+
[key: string]: any;
|
25
|
+
|
26
|
+
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
27
|
+
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
|
28
|
+
|
29
|
+
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
30
|
+
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
|
31
|
+
|
32
|
+
has(header: string, matcher?: true | AxiosHeaderMatcher): boolean;
|
33
|
+
|
34
|
+
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
35
|
+
|
36
|
+
clear(matcher?: AxiosHeaderMatcher): boolean;
|
37
|
+
|
38
|
+
normalize(format: boolean): AxiosHeaders;
|
39
|
+
|
40
|
+
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
41
|
+
|
42
|
+
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
43
|
+
|
44
|
+
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
45
|
+
|
46
|
+
static accessor(header: string | string[]): AxiosHeaders;
|
47
|
+
|
48
|
+
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
49
|
+
|
50
|
+
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
51
|
+
getContentType(parser?: RegExp): RegExpExecArray | null;
|
52
|
+
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
53
|
+
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
|
54
|
+
|
55
|
+
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
56
|
+
getContentLength(parser?: RegExp): RegExpExecArray | null;
|
57
|
+
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
58
|
+
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
|
59
|
+
|
60
|
+
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
61
|
+
getAccept(parser?: RegExp): RegExpExecArray | null;
|
62
|
+
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
63
|
+
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
|
64
|
+
|
65
|
+
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
66
|
+
getUserAgent(parser?: RegExp): RegExpExecArray | null;
|
67
|
+
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
68
|
+
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
|
69
|
+
|
70
|
+
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
71
|
+
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
|
72
|
+
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
73
|
+
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
|
74
|
+
|
75
|
+
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
76
|
+
getAuthorization(parser?: RegExp): RegExpExecArray | null;
|
77
|
+
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
78
|
+
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
79
|
+
|
80
|
+
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
|
81
|
+
}
|
82
|
+
|
83
|
+
declare class AxiosError<T = unknown, D = any> extends Error {
|
84
|
+
constructor(
|
85
|
+
message?: string,
|
86
|
+
code?: string,
|
87
|
+
config?: axios.InternalAxiosRequestConfig<D>,
|
88
|
+
request?: any,
|
89
|
+
response?: axios.AxiosResponse<T, D>
|
90
|
+
);
|
91
|
+
|
92
|
+
config?: axios.InternalAxiosRequestConfig<D>;
|
93
|
+
code?: string;
|
94
|
+
request?: any;
|
95
|
+
response?: axios.AxiosResponse<T, D>;
|
96
|
+
isAxiosError: boolean;
|
97
|
+
status?: number;
|
98
|
+
toJSON: () => object;
|
99
|
+
cause?: Error;
|
100
|
+
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
101
|
+
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
102
|
+
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
103
|
+
static readonly ERR_NETWORK = "ERR_NETWORK";
|
104
|
+
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
105
|
+
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
106
|
+
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
107
|
+
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
108
|
+
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
109
|
+
static readonly ERR_CANCELED = "ERR_CANCELED";
|
110
|
+
static readonly ECONNABORTED = "ECONNABORTED";
|
111
|
+
static readonly ETIMEDOUT = "ETIMEDOUT";
|
112
|
+
}
|
113
|
+
|
114
|
+
declare class CanceledError<T> extends AxiosError<T> {
|
115
|
+
}
|
116
|
+
|
117
|
+
declare class Axios {
|
118
|
+
constructor(config?: axios.AxiosRequestConfig);
|
119
|
+
defaults: axios.AxiosDefaults;
|
120
|
+
interceptors: {
|
121
|
+
request: axios.AxiosInterceptorManager<axios.InternalAxiosRequestConfig>;
|
122
|
+
response: axios.AxiosInterceptorManager<axios.AxiosResponse>;
|
123
|
+
};
|
124
|
+
getUri(config?: axios.AxiosRequestConfig): string;
|
125
|
+
request<T = any, R = axios.AxiosResponse<T>, D = any>(config: axios.AxiosRequestConfig<D>): Promise<R>;
|
126
|
+
get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
127
|
+
delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
128
|
+
head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
129
|
+
options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
130
|
+
post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
131
|
+
put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
132
|
+
patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
133
|
+
postForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
134
|
+
putForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
135
|
+
patchForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
136
|
+
}
|
137
|
+
|
138
|
+
declare enum HttpStatusCode {
|
139
|
+
Continue = 100,
|
140
|
+
SwitchingProtocols = 101,
|
141
|
+
Processing = 102,
|
142
|
+
EarlyHints = 103,
|
143
|
+
Ok = 200,
|
144
|
+
Created = 201,
|
145
|
+
Accepted = 202,
|
146
|
+
NonAuthoritativeInformation = 203,
|
147
|
+
NoContent = 204,
|
148
|
+
ResetContent = 205,
|
149
|
+
PartialContent = 206,
|
150
|
+
MultiStatus = 207,
|
151
|
+
AlreadyReported = 208,
|
152
|
+
ImUsed = 226,
|
153
|
+
MultipleChoices = 300,
|
154
|
+
MovedPermanently = 301,
|
155
|
+
Found = 302,
|
156
|
+
SeeOther = 303,
|
157
|
+
NotModified = 304,
|
158
|
+
UseProxy = 305,
|
159
|
+
Unused = 306,
|
160
|
+
TemporaryRedirect = 307,
|
161
|
+
PermanentRedirect = 308,
|
162
|
+
BadRequest = 400,
|
163
|
+
Unauthorized = 401,
|
164
|
+
PaymentRequired = 402,
|
165
|
+
Forbidden = 403,
|
166
|
+
NotFound = 404,
|
167
|
+
MethodNotAllowed = 405,
|
168
|
+
NotAcceptable = 406,
|
169
|
+
ProxyAuthenticationRequired = 407,
|
170
|
+
RequestTimeout = 408,
|
171
|
+
Conflict = 409,
|
172
|
+
Gone = 410,
|
173
|
+
LengthRequired = 411,
|
174
|
+
PreconditionFailed = 412,
|
175
|
+
PayloadTooLarge = 413,
|
176
|
+
UriTooLong = 414,
|
177
|
+
UnsupportedMediaType = 415,
|
178
|
+
RangeNotSatisfiable = 416,
|
179
|
+
ExpectationFailed = 417,
|
180
|
+
ImATeapot = 418,
|
181
|
+
MisdirectedRequest = 421,
|
182
|
+
UnprocessableEntity = 422,
|
183
|
+
Locked = 423,
|
184
|
+
FailedDependency = 424,
|
185
|
+
TooEarly = 425,
|
186
|
+
UpgradeRequired = 426,
|
187
|
+
PreconditionRequired = 428,
|
188
|
+
TooManyRequests = 429,
|
189
|
+
RequestHeaderFieldsTooLarge = 431,
|
190
|
+
UnavailableForLegalReasons = 451,
|
191
|
+
InternalServerError = 500,
|
192
|
+
NotImplemented = 501,
|
193
|
+
BadGateway = 502,
|
194
|
+
ServiceUnavailable = 503,
|
195
|
+
GatewayTimeout = 504,
|
196
|
+
HttpVersionNotSupported = 505,
|
197
|
+
VariantAlsoNegotiates = 506,
|
198
|
+
InsufficientStorage = 507,
|
199
|
+
LoopDetected = 508,
|
200
|
+
NotExtended = 510,
|
201
|
+
NetworkAuthenticationRequired = 511,
|
202
|
+
}
|
203
|
+
|
204
|
+
type InternalAxiosError<T = unknown, D = any> = AxiosError<T, D>;
|
205
|
+
|
206
|
+
declare namespace axios {
|
207
|
+
type AxiosError<T = unknown, D = any> = InternalAxiosError<T, D>;
|
208
|
+
|
209
|
+
type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {
|
210
|
+
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
211
|
+
} & {
|
212
|
+
'Content-Type': ContentType
|
213
|
+
}>;
|
214
|
+
|
215
|
+
type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
216
|
+
|
217
|
+
type RawCommonResponseHeaders = {
|
218
|
+
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
219
|
+
} & {
|
220
|
+
"set-cookie": string[];
|
221
|
+
};
|
222
|
+
|
223
|
+
type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
|
224
|
+
|
225
|
+
type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
226
|
+
|
227
|
+
interface AxiosRequestTransformer {
|
228
|
+
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
229
|
+
}
|
230
|
+
|
231
|
+
interface AxiosResponseTransformer {
|
232
|
+
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
233
|
+
}
|
234
|
+
|
235
|
+
interface AxiosAdapter {
|
236
|
+
(config: InternalAxiosRequestConfig): AxiosPromise;
|
237
|
+
}
|
238
|
+
|
239
|
+
interface AxiosBasicCredentials {
|
240
|
+
username: string;
|
241
|
+
password: string;
|
242
|
+
}
|
243
|
+
|
244
|
+
interface AxiosProxyConfig {
|
245
|
+
host: string;
|
246
|
+
port: number;
|
247
|
+
auth?: {
|
248
|
+
username: string;
|
249
|
+
password: string;
|
250
|
+
};
|
251
|
+
protocol?: string;
|
252
|
+
}
|
253
|
+
|
254
|
+
type Method =
|
255
|
+
| 'get' | 'GET'
|
256
|
+
| 'delete' | 'DELETE'
|
257
|
+
| 'head' | 'HEAD'
|
258
|
+
| 'options' | 'OPTIONS'
|
259
|
+
| 'post' | 'POST'
|
260
|
+
| 'put' | 'PUT'
|
261
|
+
| 'patch' | 'PATCH'
|
262
|
+
| 'purge' | 'PURGE'
|
263
|
+
| 'link' | 'LINK'
|
264
|
+
| 'unlink' | 'UNLINK';
|
265
|
+
|
266
|
+
type ResponseType =
|
267
|
+
| 'arraybuffer'
|
268
|
+
| 'blob'
|
269
|
+
| 'document'
|
270
|
+
| 'json'
|
271
|
+
| 'text'
|
272
|
+
| 'stream';
|
273
|
+
|
274
|
+
type responseEncoding =
|
275
|
+
| 'ascii' | 'ASCII'
|
276
|
+
| 'ansi' | 'ANSI'
|
277
|
+
| 'binary' | 'BINARY'
|
278
|
+
| 'base64' | 'BASE64'
|
279
|
+
| 'base64url' | 'BASE64URL'
|
280
|
+
| 'hex' | 'HEX'
|
281
|
+
| 'latin1' | 'LATIN1'
|
282
|
+
| 'ucs-2' | 'UCS-2'
|
283
|
+
| 'ucs2' | 'UCS2'
|
284
|
+
| 'utf-8' | 'UTF-8'
|
285
|
+
| 'utf8' | 'UTF8'
|
286
|
+
| 'utf16le' | 'UTF16LE';
|
287
|
+
|
288
|
+
interface TransitionalOptions {
|
289
|
+
silentJSONParsing?: boolean;
|
290
|
+
forcedJSONParsing?: boolean;
|
291
|
+
clarifyTimeoutError?: boolean;
|
292
|
+
}
|
293
|
+
|
294
|
+
interface GenericAbortSignal {
|
295
|
+
readonly aborted: boolean;
|
296
|
+
onabort?: ((...args: any) => any) | null;
|
297
|
+
addEventListener?: (...args: any) => any;
|
298
|
+
removeEventListener?: (...args: any) => any;
|
299
|
+
}
|
300
|
+
|
301
|
+
interface FormDataVisitorHelpers {
|
302
|
+
defaultVisitor: SerializerVisitor;
|
303
|
+
convertValue: (value: any) => any;
|
304
|
+
isVisitable: (value: any) => boolean;
|
305
|
+
}
|
306
|
+
|
307
|
+
interface SerializerVisitor {
|
308
|
+
(
|
309
|
+
this: GenericFormData,
|
310
|
+
value: any,
|
311
|
+
key: string | number,
|
312
|
+
path: null | Array<string | number>,
|
313
|
+
helpers: FormDataVisitorHelpers
|
314
|
+
): boolean;
|
315
|
+
}
|
316
|
+
|
317
|
+
interface SerializerOptions {
|
318
|
+
visitor?: SerializerVisitor;
|
319
|
+
dots?: boolean;
|
320
|
+
metaTokens?: boolean;
|
321
|
+
indexes?: boolean | null;
|
322
|
+
}
|
323
|
+
|
324
|
+
// tslint:disable-next-line
|
325
|
+
interface FormSerializerOptions extends SerializerOptions {
|
326
|
+
}
|
327
|
+
|
328
|
+
interface ParamEncoder {
|
329
|
+
(value: any, defaultEncoder: (value: any) => any): any;
|
330
|
+
}
|
331
|
+
|
332
|
+
interface CustomParamsSerializer {
|
333
|
+
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
|
334
|
+
}
|
335
|
+
|
336
|
+
interface ParamsSerializerOptions extends SerializerOptions {
|
337
|
+
encode?: ParamEncoder;
|
338
|
+
serialize?: CustomParamsSerializer;
|
339
|
+
}
|
340
|
+
|
341
|
+
type MaxUploadRate = number;
|
342
|
+
|
343
|
+
type MaxDownloadRate = number;
|
344
|
+
|
345
|
+
type BrowserProgressEvent = any;
|
346
|
+
|
347
|
+
interface AxiosProgressEvent {
|
348
|
+
loaded: number;
|
349
|
+
total?: number;
|
350
|
+
progress?: number;
|
351
|
+
bytes: number;
|
352
|
+
rate?: number;
|
353
|
+
estimated?: number;
|
354
|
+
upload?: boolean;
|
355
|
+
download?: boolean;
|
356
|
+
event?: BrowserProgressEvent;
|
357
|
+
}
|
358
|
+
|
359
|
+
type Milliseconds = number;
|
360
|
+
|
361
|
+
type AxiosAdapterName = 'xhr' | 'http' | string;
|
362
|
+
|
363
|
+
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
364
|
+
|
365
|
+
interface AxiosRequestConfig<D = any> {
|
366
|
+
url?: string;
|
367
|
+
method?: Method | string;
|
368
|
+
baseURL?: string;
|
369
|
+
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
370
|
+
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
371
|
+
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
372
|
+
params?: any;
|
373
|
+
paramsSerializer?: ParamsSerializerOptions;
|
374
|
+
data?: D;
|
375
|
+
timeout?: Milliseconds;
|
376
|
+
timeoutErrorMessage?: string;
|
377
|
+
withCredentials?: boolean;
|
378
|
+
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
379
|
+
auth?: AxiosBasicCredentials;
|
380
|
+
responseType?: ResponseType;
|
381
|
+
responseEncoding?: responseEncoding | string;
|
382
|
+
xsrfCookieName?: string;
|
383
|
+
xsrfHeaderName?: string;
|
384
|
+
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
385
|
+
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
386
|
+
maxContentLength?: number;
|
387
|
+
validateStatus?: ((status: number) => boolean) | null;
|
388
|
+
maxBodyLength?: number;
|
389
|
+
maxRedirects?: number;
|
390
|
+
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
391
|
+
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
|
392
|
+
socketPath?: string | null;
|
393
|
+
httpAgent?: any;
|
394
|
+
httpsAgent?: any;
|
395
|
+
proxy?: AxiosProxyConfig | false;
|
396
|
+
cancelToken?: CancelToken;
|
397
|
+
decompress?: boolean;
|
398
|
+
transitional?: TransitionalOptions;
|
399
|
+
signal?: GenericAbortSignal;
|
400
|
+
insecureHTTPParser?: boolean;
|
401
|
+
env?: {
|
402
|
+
FormData?: new (...args: any[]) => object;
|
403
|
+
};
|
404
|
+
formSerializer?: FormSerializerOptions;
|
405
|
+
}
|
406
|
+
|
407
|
+
// Alias
|
408
|
+
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
409
|
+
|
410
|
+
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
|
411
|
+
headers: AxiosRequestHeaders;
|
412
|
+
}
|
413
|
+
|
414
|
+
interface HeadersDefaults {
|
415
|
+
common: RawAxiosRequestHeaders;
|
416
|
+
delete: RawAxiosRequestHeaders;
|
417
|
+
get: RawAxiosRequestHeaders;
|
418
|
+
head: RawAxiosRequestHeaders;
|
419
|
+
post: RawAxiosRequestHeaders;
|
420
|
+
put: RawAxiosRequestHeaders;
|
421
|
+
patch: RawAxiosRequestHeaders;
|
422
|
+
options?: RawAxiosRequestHeaders;
|
423
|
+
purge?: RawAxiosRequestHeaders;
|
424
|
+
link?: RawAxiosRequestHeaders;
|
425
|
+
unlink?: RawAxiosRequestHeaders;
|
426
|
+
}
|
427
|
+
|
428
|
+
interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
429
|
+
headers: HeadersDefaults;
|
430
|
+
}
|
431
|
+
|
432
|
+
interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
433
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
434
|
+
}
|
435
|
+
|
436
|
+
interface AxiosResponse<T = any, D = any> {
|
437
|
+
data: T;
|
438
|
+
status: number;
|
439
|
+
statusText: string;
|
440
|
+
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
441
|
+
config: InternalAxiosRequestConfig<D>;
|
442
|
+
request?: any;
|
443
|
+
}
|
444
|
+
|
445
|
+
type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
446
|
+
|
447
|
+
interface CancelStatic {
|
448
|
+
new (message?: string): Cancel;
|
449
|
+
}
|
450
|
+
|
451
|
+
interface Cancel {
|
452
|
+
message: string | undefined;
|
453
|
+
}
|
454
|
+
|
455
|
+
interface Canceler {
|
456
|
+
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
457
|
+
}
|
458
|
+
|
459
|
+
interface CancelTokenStatic {
|
460
|
+
new (executor: (cancel: Canceler) => void): CancelToken;
|
461
|
+
source(): CancelTokenSource;
|
462
|
+
}
|
463
|
+
|
464
|
+
interface CancelToken {
|
465
|
+
promise: Promise<Cancel>;
|
466
|
+
reason?: Cancel;
|
467
|
+
throwIfRequested(): void;
|
468
|
+
}
|
469
|
+
|
470
|
+
interface CancelTokenSource {
|
471
|
+
token: CancelToken;
|
472
|
+
cancel: Canceler;
|
473
|
+
}
|
474
|
+
|
475
|
+
interface AxiosInterceptorOptions {
|
476
|
+
synchronous?: boolean;
|
477
|
+
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
478
|
+
}
|
479
|
+
|
480
|
+
interface AxiosInterceptorManager<V> {
|
481
|
+
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
|
482
|
+
eject(id: number): void;
|
483
|
+
clear(): void;
|
484
|
+
}
|
485
|
+
|
486
|
+
interface AxiosInstance extends Axios {
|
487
|
+
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
488
|
+
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
489
|
+
|
490
|
+
defaults: Omit<AxiosDefaults, 'headers'> & {
|
491
|
+
headers: HeadersDefaults & {
|
492
|
+
[key: string]: AxiosHeaderValue
|
493
|
+
}
|
494
|
+
};
|
495
|
+
}
|
496
|
+
|
497
|
+
interface GenericFormData {
|
498
|
+
append(name: string, value: any, options?: any): any;
|
499
|
+
}
|
500
|
+
|
501
|
+
interface GenericHTMLFormElement {
|
502
|
+
name: string;
|
503
|
+
method: string;
|
504
|
+
submit(): void;
|
505
|
+
}
|
506
|
+
|
507
|
+
interface AxiosStatic extends AxiosInstance {
|
508
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
509
|
+
Cancel: CancelStatic;
|
510
|
+
CancelToken: CancelTokenStatic;
|
511
|
+
Axios: typeof Axios;
|
512
|
+
AxiosError: typeof AxiosError;
|
513
|
+
CanceledError: typeof CanceledError;
|
514
|
+
HttpStatusCode: typeof HttpStatusCode;
|
515
|
+
readonly VERSION: string;
|
516
|
+
isCancel(value: any): value is Cancel;
|
517
|
+
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
518
|
+
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
519
|
+
isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
520
|
+
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
521
|
+
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
522
|
+
AxiosHeaders: typeof AxiosHeaders;
|
523
|
+
}
|
524
|
+
}
|
525
|
+
|
526
|
+
declare const axios: axios.AxiosStatic;
|
527
|
+
|
528
|
+
export = axios;
|