axios 0.27.2 → 1.1.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 +232 -920
- package/LICENSE +4 -16
- package/README.md +386 -103
- package/SECURITY.md +4 -3
- package/UPGRADE_GUIDE.md +1 -166
- package/bin/ssl_hotfix.js +22 -0
- package/dist/axios.js +2430 -2367
- package/dist/axios.js.map +1 -0
- package/dist/axios.min.js +2 -3
- package/dist/axios.min.js.map +1 -0
- package/dist/esm/axios.js +2950 -0
- package/dist/esm/axios.js.map +1 -0
- package/dist/esm/axios.min.js +2 -0
- package/dist/esm/axios.min.js.map +1 -0
- package/dist/node/axios.cjs +3764 -0
- package/dist/node/axios.cjs.map +1 -0
- package/gulpfile.js +88 -0
- package/index.d.ts +299 -70
- package/index.js +32 -1
- package/karma.conf.cjs +250 -0
- package/lib/adapters/http.js +378 -211
- package/lib/adapters/index.js +33 -0
- package/lib/adapters/xhr.js +81 -57
- package/lib/axios.js +34 -22
- package/lib/cancel/CancelToken.js +91 -89
- package/lib/cancel/CanceledError.js +9 -6
- package/lib/cancel/isCancel.js +2 -2
- package/lib/core/Axios.js +133 -98
- package/lib/core/AxiosError.js +22 -8
- package/lib/core/AxiosHeaders.js +268 -0
- package/lib/core/InterceptorManager.js +62 -45
- package/lib/core/buildFullPath.js +5 -4
- package/lib/core/dispatchRequest.js +21 -32
- package/lib/core/mergeConfig.js +8 -7
- package/lib/core/settle.js +6 -4
- package/lib/core/transformData.js +15 -9
- package/lib/defaults/index.js +77 -38
- package/lib/defaults/transitional.js +1 -1
- package/lib/env/classes/FormData.js +2 -0
- package/lib/env/data.js +1 -3
- package/lib/helpers/AxiosTransformStream.js +191 -0
- package/lib/helpers/AxiosURLSearchParams.js +58 -0
- package/lib/helpers/bind.js +3 -7
- package/lib/helpers/buildURL.js +26 -33
- package/lib/helpers/combineURLs.js +3 -2
- package/lib/helpers/cookies.js +43 -44
- package/lib/helpers/deprecatedMethod.js +4 -2
- package/lib/helpers/formDataToJSON.js +92 -0
- package/lib/helpers/fromDataURI.js +53 -0
- package/lib/helpers/isAbsoluteURL.js +3 -2
- package/lib/helpers/isAxiosError.js +4 -3
- package/lib/helpers/isURLSameOrigin.js +44 -45
- package/lib/helpers/null.js +1 -1
- package/lib/helpers/parseHeaders.js +24 -22
- package/lib/helpers/parseProtocol.js +3 -3
- package/lib/helpers/speedometer.js +55 -0
- package/lib/helpers/spread.js +3 -2
- package/lib/helpers/throttle.js +33 -0
- package/lib/helpers/toFormData.js +193 -36
- package/lib/helpers/toURLEncodedForm.js +18 -0
- package/lib/helpers/validator.js +20 -15
- package/lib/platform/browser/classes/FormData.js +3 -0
- package/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/lib/platform/browser/index.js +43 -0
- package/lib/platform/index.js +3 -0
- package/lib/platform/node/classes/FormData.js +3 -0
- package/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/lib/platform/node/index.js +12 -0
- package/lib/utils.js +321 -178
- package/package.json +70 -23
- package/rollup.config.js +90 -0
- package/dist/axios.map +0 -1
- package/dist/axios.min.map +0 -1
- package/lib/defaults/env/FormData.js +0 -2
- package/lib/helpers/normalizeHeaderName.js +0 -12
package/index.d.ts
CHANGED
@@ -1,16 +1,87 @@
|
|
1
|
-
// TypeScript Version:
|
2
|
-
|
1
|
+
// TypeScript Version: 4.1
|
2
|
+
type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
3
|
+
type RawAxiosHeaders = Record<string, AxiosHeaderValue>;
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
type MethodsHeaders = {
|
6
|
+
[Key in Method as Lowercase<Key>]: AxiosHeaders;
|
6
7
|
};
|
7
8
|
|
9
|
+
interface CommonHeaders {
|
10
|
+
common: AxiosHeaders;
|
11
|
+
}
|
12
|
+
|
13
|
+
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
|
14
|
+
|
15
|
+
type AxiosHeaderSetter = (value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher) => AxiosHeaders;
|
16
|
+
|
17
|
+
type AxiosHeaderGetter = ((parser?: RegExp) => RegExpExecArray | null) |
|
18
|
+
((matcher?: AxiosHeaderMatcher) => AxiosHeaderValue);
|
19
|
+
|
20
|
+
type AxiosHeaderTester = (matcher?: AxiosHeaderMatcher) => boolean;
|
21
|
+
|
22
|
+
export class AxiosHeaders {
|
23
|
+
constructor(
|
24
|
+
headers?: RawAxiosHeaders | AxiosHeaders,
|
25
|
+
defaultHeaders?: RawAxiosHeaders | AxiosHeaders
|
26
|
+
);
|
27
|
+
|
28
|
+
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
29
|
+
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
|
30
|
+
|
31
|
+
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
32
|
+
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
|
33
|
+
|
34
|
+
has(header: string, matcher?: true | AxiosHeaderMatcher): boolean;
|
35
|
+
|
36
|
+
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
37
|
+
|
38
|
+
clear(): boolean;
|
39
|
+
|
40
|
+
normalize(format: boolean): 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
|
+
setContentType: AxiosHeaderSetter;
|
49
|
+
getContentType: AxiosHeaderGetter;
|
50
|
+
hasContentType: AxiosHeaderTester;
|
51
|
+
|
52
|
+
setContentLength: AxiosHeaderSetter;
|
53
|
+
getContentLength: AxiosHeaderGetter;
|
54
|
+
hasContentLength: AxiosHeaderTester;
|
55
|
+
|
56
|
+
setAccept: AxiosHeaderSetter;
|
57
|
+
getAccept: AxiosHeaderGetter;
|
58
|
+
hasAccept: AxiosHeaderTester;
|
59
|
+
|
60
|
+
setUserAgent: AxiosHeaderSetter;
|
61
|
+
getUserAgent: AxiosHeaderGetter;
|
62
|
+
hasUserAgent: AxiosHeaderTester;
|
63
|
+
|
64
|
+
setContentEncoding: AxiosHeaderSetter;
|
65
|
+
getContentEncoding: AxiosHeaderGetter;
|
66
|
+
hasContentEncoding: AxiosHeaderTester;
|
67
|
+
}
|
68
|
+
|
69
|
+
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
|
70
|
+
|
71
|
+
export type AxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders> & AxiosHeaders;
|
72
|
+
|
73
|
+
export type RawAxiosResponseHeaders = Partial<Record<string, string> & {
|
74
|
+
"set-cookie"?: string[]
|
75
|
+
}>;
|
76
|
+
|
77
|
+
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
78
|
+
|
8
79
|
export interface AxiosRequestTransformer {
|
9
|
-
(data: any, headers
|
80
|
+
(this: AxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
10
81
|
}
|
11
82
|
|
12
83
|
export interface AxiosResponseTransformer {
|
13
|
-
(data: any, headers?:
|
84
|
+
(this: AxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
14
85
|
}
|
15
86
|
|
16
87
|
export interface AxiosAdapter {
|
@@ -32,39 +103,105 @@ export interface AxiosProxyConfig {
|
|
32
103
|
protocol?: string;
|
33
104
|
}
|
34
105
|
|
106
|
+
export enum HttpStatusCode {
|
107
|
+
Continue = 100,
|
108
|
+
SwitchingProtocols = 101,
|
109
|
+
Processing = 102,
|
110
|
+
EarlyHints = 103,
|
111
|
+
Ok = 200,
|
112
|
+
Created = 201,
|
113
|
+
Accepted = 202,
|
114
|
+
NonAuthoritativeInformation = 203,
|
115
|
+
NoContent = 204,
|
116
|
+
ResetContent = 205,
|
117
|
+
PartialContent = 206,
|
118
|
+
MultiStatus = 207,
|
119
|
+
AlreadyReported = 208,
|
120
|
+
ImUsed = 226,
|
121
|
+
MultipleChoices = 300,
|
122
|
+
MovedPermanently = 301,
|
123
|
+
Found = 302,
|
124
|
+
SeeOther = 303,
|
125
|
+
NotModified = 304,
|
126
|
+
UseProxy = 305,
|
127
|
+
Unused = 306,
|
128
|
+
TemporaryRedirect = 307,
|
129
|
+
PermanentRedirect = 308,
|
130
|
+
BadRequest = 400,
|
131
|
+
Unauthorized = 401,
|
132
|
+
PaymentRequired = 402,
|
133
|
+
Forbidden = 403,
|
134
|
+
NotFound = 404,
|
135
|
+
MethodNotAllowed = 405,
|
136
|
+
NotAcceptable = 406,
|
137
|
+
ProxyAuthenticationRequired = 407,
|
138
|
+
RequestTimeout = 408,
|
139
|
+
Conflict = 409,
|
140
|
+
Gone = 410,
|
141
|
+
LengthRequired = 411,
|
142
|
+
PreconditionFailed = 412,
|
143
|
+
PayloadTooLarge = 413,
|
144
|
+
UriTooLong = 414,
|
145
|
+
UnsupportedMediaType = 415,
|
146
|
+
RangeNotSatisfiable = 416,
|
147
|
+
ExpectationFailed = 417,
|
148
|
+
ImATeapot = 418,
|
149
|
+
MisdirectedRequest = 421,
|
150
|
+
UnprocessableEntity = 422,
|
151
|
+
Locked = 423,
|
152
|
+
FailedDependency = 424,
|
153
|
+
TooEarly = 425,
|
154
|
+
UpgradeRequired = 426,
|
155
|
+
PreconditionRequired = 428,
|
156
|
+
TooManyRequests = 429,
|
157
|
+
RequestHeaderFieldsTooLarge = 431,
|
158
|
+
UnavailableForLegalReasons = 451,
|
159
|
+
InternalServerError = 500,
|
160
|
+
NotImplemented = 501,
|
161
|
+
BadGateway = 502,
|
162
|
+
ServiceUnavailable = 503,
|
163
|
+
GatewayTimeout = 504,
|
164
|
+
HttpVersionNotSupported = 505,
|
165
|
+
VariantAlsoNegotiates = 506,
|
166
|
+
InsufficientStorage = 507,
|
167
|
+
LoopDetected = 508,
|
168
|
+
NotExtended = 510,
|
169
|
+
NetworkAuthenticationRequired = 511,
|
170
|
+
}
|
171
|
+
|
35
172
|
export type Method =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
173
|
+
| 'get' | 'GET'
|
174
|
+
| 'delete' | 'DELETE'
|
175
|
+
| 'head' | 'HEAD'
|
176
|
+
| 'options' | 'OPTIONS'
|
177
|
+
| 'post' | 'POST'
|
178
|
+
| 'put' | 'PUT'
|
179
|
+
| 'patch' | 'PATCH'
|
180
|
+
| 'purge' | 'PURGE'
|
181
|
+
| 'link' | 'LINK'
|
182
|
+
| 'unlink' | 'UNLINK';
|
46
183
|
|
47
184
|
export type ResponseType =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
185
|
+
| 'arraybuffer'
|
186
|
+
| 'blob'
|
187
|
+
| 'document'
|
188
|
+
| 'json'
|
189
|
+
| 'text'
|
190
|
+
| 'stream';
|
191
|
+
|
192
|
+
export type responseEncoding =
|
193
|
+
| 'ascii' | 'ASCII'
|
194
|
+
| 'ansi' | 'ANSI'
|
195
|
+
| 'binary' | 'BINARY'
|
196
|
+
| 'base64' | 'BASE64'
|
197
|
+
| 'base64url' | 'BASE64URL'
|
198
|
+
| 'hex' | 'HEX'
|
199
|
+
| 'latin1' | 'LATIN1'
|
200
|
+
| 'ucs-2' | 'UCS-2'
|
201
|
+
| 'ucs2' | 'UCS2'
|
202
|
+
| 'utf-8' | 'UTF-8'
|
203
|
+
| 'utf8' | 'UTF8'
|
204
|
+
| 'utf16le' | 'UTF16LE';
|
68
205
|
|
69
206
|
export interface TransitionalOptions {
|
70
207
|
silentJSONParsing?: boolean;
|
@@ -72,17 +209,81 @@ export interface TransitionalOptions {
|
|
72
209
|
clarifyTimeoutError?: boolean;
|
73
210
|
}
|
74
211
|
|
212
|
+
export interface GenericAbortSignal {
|
213
|
+
readonly aborted: boolean;
|
214
|
+
onabort?: ((...args: any) => any) | null;
|
215
|
+
addEventListener?: (...args: any) => any;
|
216
|
+
removeEventListener?: (...args: any) => any;
|
217
|
+
}
|
218
|
+
|
219
|
+
export interface FormDataVisitorHelpers {
|
220
|
+
defaultVisitor: SerializerVisitor;
|
221
|
+
convertValue: (value: any) => any;
|
222
|
+
isVisitable: (value: any) => boolean;
|
223
|
+
}
|
224
|
+
|
225
|
+
export interface SerializerVisitor {
|
226
|
+
(
|
227
|
+
this: GenericFormData,
|
228
|
+
value: any,
|
229
|
+
key: string | number,
|
230
|
+
path: null | Array<string | number>,
|
231
|
+
helpers: FormDataVisitorHelpers
|
232
|
+
): boolean;
|
233
|
+
}
|
234
|
+
|
235
|
+
export interface SerializerOptions {
|
236
|
+
visitor?: SerializerVisitor;
|
237
|
+
dots?: boolean;
|
238
|
+
metaTokens?: boolean;
|
239
|
+
indexes?: boolean | null;
|
240
|
+
}
|
241
|
+
|
242
|
+
// tslint:disable-next-line
|
243
|
+
export interface FormSerializerOptions extends SerializerOptions {
|
244
|
+
}
|
245
|
+
|
246
|
+
export interface ParamEncoder {
|
247
|
+
(value: any, defaultEncoder: (value: any) => any): any;
|
248
|
+
}
|
249
|
+
|
250
|
+
export interface CustomParamsSerializer {
|
251
|
+
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
|
252
|
+
}
|
253
|
+
|
254
|
+
export interface ParamsSerializerOptions extends SerializerOptions {
|
255
|
+
encode?: ParamEncoder;
|
256
|
+
serialize?: CustomParamsSerializer;
|
257
|
+
}
|
258
|
+
|
259
|
+
type MaxUploadRate = number;
|
260
|
+
|
261
|
+
type MaxDownloadRate = number;
|
262
|
+
|
263
|
+
export interface AxiosProgressEvent {
|
264
|
+
loaded: number;
|
265
|
+
total?: number;
|
266
|
+
progress?: number;
|
267
|
+
bytes: number;
|
268
|
+
rate?: number;
|
269
|
+
estimated?: number;
|
270
|
+
upload?: boolean;
|
271
|
+
download?: boolean;
|
272
|
+
}
|
273
|
+
|
274
|
+
type Milliseconds = number;
|
275
|
+
|
75
276
|
export interface AxiosRequestConfig<D = any> {
|
76
277
|
url?: string;
|
77
278
|
method?: Method | string;
|
78
279
|
baseURL?: string;
|
79
280
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
80
281
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
81
|
-
headers?:
|
282
|
+
headers?: RawAxiosRequestHeaders;
|
82
283
|
params?: any;
|
83
|
-
paramsSerializer?:
|
284
|
+
paramsSerializer?: ParamsSerializerOptions;
|
84
285
|
data?: D;
|
85
|
-
timeout?:
|
286
|
+
timeout?: Milliseconds;
|
86
287
|
timeoutErrorMessage?: string;
|
87
288
|
withCredentials?: boolean;
|
88
289
|
adapter?: AxiosAdapter;
|
@@ -91,12 +292,13 @@ export interface AxiosRequestConfig<D = any> {
|
|
91
292
|
responseEncoding?: responseEncoding | string;
|
92
293
|
xsrfCookieName?: string;
|
93
294
|
xsrfHeaderName?: string;
|
94
|
-
onUploadProgress?: (progressEvent:
|
95
|
-
onDownloadProgress?: (progressEvent:
|
295
|
+
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
296
|
+
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
96
297
|
maxContentLength?: number;
|
97
298
|
validateStatus?: ((status: number) => boolean) | null;
|
98
299
|
maxBodyLength?: number;
|
99
300
|
maxRedirects?: number;
|
301
|
+
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
100
302
|
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
|
101
303
|
socketPath?: string | null;
|
102
304
|
httpAgent?: any;
|
@@ -105,56 +307,62 @@ export interface AxiosRequestConfig<D = any> {
|
|
105
307
|
cancelToken?: CancelToken;
|
106
308
|
decompress?: boolean;
|
107
309
|
transitional?: TransitionalOptions;
|
108
|
-
signal?:
|
310
|
+
signal?: GenericAbortSignal;
|
109
311
|
insecureHTTPParser?: boolean;
|
110
312
|
env?: {
|
111
313
|
FormData?: new (...args: any[]) => object;
|
112
314
|
};
|
315
|
+
formSerializer?: FormSerializerOptions;
|
113
316
|
}
|
114
317
|
|
115
318
|
export interface HeadersDefaults {
|
116
|
-
common:
|
117
|
-
delete:
|
118
|
-
get:
|
119
|
-
head:
|
120
|
-
post:
|
121
|
-
put:
|
122
|
-
patch:
|
123
|
-
options?:
|
124
|
-
purge?:
|
125
|
-
link?:
|
126
|
-
unlink?:
|
319
|
+
common: RawAxiosRequestHeaders;
|
320
|
+
delete: RawAxiosRequestHeaders;
|
321
|
+
get: RawAxiosRequestHeaders;
|
322
|
+
head: RawAxiosRequestHeaders;
|
323
|
+
post: RawAxiosRequestHeaders;
|
324
|
+
put: RawAxiosRequestHeaders;
|
325
|
+
patch: RawAxiosRequestHeaders;
|
326
|
+
options?: RawAxiosRequestHeaders;
|
327
|
+
purge?: RawAxiosRequestHeaders;
|
328
|
+
link?: RawAxiosRequestHeaders;
|
329
|
+
unlink?: RawAxiosRequestHeaders;
|
127
330
|
}
|
128
331
|
|
129
332
|
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
130
333
|
headers: HeadersDefaults;
|
131
334
|
}
|
132
335
|
|
336
|
+
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
337
|
+
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
338
|
+
}
|
339
|
+
|
133
340
|
export interface AxiosResponse<T = any, D = any> {
|
134
341
|
data: T;
|
135
342
|
status: number;
|
136
343
|
statusText: string;
|
137
|
-
headers: AxiosResponseHeaders;
|
344
|
+
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
138
345
|
config: AxiosRequestConfig<D>;
|
139
346
|
request?: any;
|
140
347
|
}
|
141
348
|
|
142
349
|
export class AxiosError<T = unknown, D = any> extends Error {
|
143
350
|
constructor(
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
351
|
+
message?: string,
|
352
|
+
code?: string,
|
353
|
+
config?: AxiosRequestConfig<D>,
|
354
|
+
request?: any,
|
355
|
+
response?: AxiosResponse<T, D>
|
149
356
|
);
|
150
357
|
|
151
|
-
config
|
358
|
+
config?: AxiosRequestConfig<D>;
|
152
359
|
code?: string;
|
153
360
|
request?: any;
|
154
361
|
response?: AxiosResponse<T, D>;
|
155
362
|
isAxiosError: boolean;
|
156
|
-
status?:
|
363
|
+
status?: number;
|
157
364
|
toJSON: () => object;
|
365
|
+
cause?: Error;
|
158
366
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
159
367
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
160
368
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
@@ -162,6 +370,8 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
162
370
|
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
163
371
|
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
164
372
|
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
373
|
+
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
374
|
+
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
165
375
|
static readonly ERR_CANCELED = "ERR_CANCELED";
|
166
376
|
static readonly ECONNABORTED = "ECONNABORTED";
|
167
377
|
static readonly ETIMEDOUT = "ETIMEDOUT";
|
@@ -170,8 +380,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
170
380
|
export class CanceledError<T> extends AxiosError<T> {
|
171
381
|
}
|
172
382
|
|
173
|
-
export
|
174
|
-
}
|
383
|
+
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
175
384
|
|
176
385
|
export interface CancelStatic {
|
177
386
|
new (message?: string): Cancel;
|
@@ -182,7 +391,7 @@ export interface Cancel {
|
|
182
391
|
}
|
183
392
|
|
184
393
|
export interface Canceler {
|
185
|
-
(message?: string): void;
|
394
|
+
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
186
395
|
}
|
187
396
|
|
188
397
|
export interface CancelTokenStatic {
|
@@ -207,8 +416,9 @@ export interface AxiosInterceptorOptions {
|
|
207
416
|
}
|
208
417
|
|
209
418
|
export interface AxiosInterceptorManager<V> {
|
210
|
-
use
|
419
|
+
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
|
211
420
|
eject(id: number): void;
|
421
|
+
clear(): void;
|
212
422
|
}
|
213
423
|
|
214
424
|
export class Axios {
|
@@ -233,20 +443,39 @@ export class Axios {
|
|
233
443
|
}
|
234
444
|
|
235
445
|
export interface AxiosInstance extends Axios {
|
236
|
-
(config: AxiosRequestConfig):
|
237
|
-
(url: string, config?: AxiosRequestConfig):
|
446
|
+
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
447
|
+
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
448
|
+
|
449
|
+
defaults: Omit<AxiosDefaults, 'headers'> & {
|
450
|
+
headers: HeadersDefaults & {
|
451
|
+
[key: string]: AxiosHeaderValue
|
452
|
+
}
|
453
|
+
};
|
454
|
+
}
|
455
|
+
|
456
|
+
export interface GenericFormData {
|
457
|
+
append(name: string, value: any, options?: any): any;
|
458
|
+
}
|
459
|
+
|
460
|
+
export interface GenericHTMLFormElement {
|
461
|
+
name: string;
|
462
|
+
method: string;
|
463
|
+
submit(): void;
|
238
464
|
}
|
239
465
|
|
240
466
|
export interface AxiosStatic extends AxiosInstance {
|
241
|
-
create(config?:
|
467
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
242
468
|
Cancel: CancelStatic;
|
243
469
|
CancelToken: CancelTokenStatic;
|
244
470
|
Axios: typeof Axios;
|
471
|
+
AxiosError: typeof AxiosError;
|
245
472
|
readonly VERSION: string;
|
246
|
-
isCancel(value: any):
|
473
|
+
isCancel(value: any): value is Cancel;
|
247
474
|
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
248
475
|
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
249
|
-
isAxiosError(payload: any): payload is AxiosError
|
476
|
+
isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
477
|
+
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
478
|
+
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
250
479
|
}
|
251
480
|
|
252
481
|
declare const axios: AxiosStatic;
|
package/index.js
CHANGED
@@ -1 +1,32 @@
|
|
1
|
-
|
1
|
+
import axios from './lib/axios.js';
|
2
|
+
|
3
|
+
// Keep top-level export same with static properties
|
4
|
+
// so that it can keep same with es module or cjs
|
5
|
+
const {
|
6
|
+
Axios,
|
7
|
+
AxiosError,
|
8
|
+
CanceledError,
|
9
|
+
isCancel,
|
10
|
+
CancelToken,
|
11
|
+
VERSION,
|
12
|
+
all,
|
13
|
+
Cancel,
|
14
|
+
isAxiosError,
|
15
|
+
spread,
|
16
|
+
toFormData
|
17
|
+
} = axios;
|
18
|
+
|
19
|
+
export default axios;
|
20
|
+
export {
|
21
|
+
Axios,
|
22
|
+
AxiosError,
|
23
|
+
CanceledError,
|
24
|
+
isCancel,
|
25
|
+
CancelToken,
|
26
|
+
VERSION,
|
27
|
+
all,
|
28
|
+
Cancel,
|
29
|
+
isAxiosError,
|
30
|
+
spread,
|
31
|
+
toFormData
|
32
|
+
}
|