axios 0.27.2 → 1.0.0
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 +178 -940
- package/LICENSE +4 -16
- package/README.md +292 -93
- package/SECURITY.md +4 -3
- package/UPGRADE_GUIDE.md +1 -166
- package/bin/ssl_hotfix.js +22 -0
- package/dist/axios.js +2537 -2211
- 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 +2942 -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 +3750 -0
- package/dist/node/axios.cjs.map +1 -0
- package/gulpfile.js +88 -0
- package/index.d.ts +293 -70
- package/index.js +2 -1
- package/karma.conf.cjs +250 -0
- package/lib/adapters/http.js +371 -212
- 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 +127 -99
- package/lib/core/AxiosError.js +22 -8
- package/lib/core/AxiosHeaders.js +274 -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 +24 -38
- 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 +320 -177
- package/package.json +69 -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 = 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(): 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,76 @@ export interface TransitionalOptions {
|
|
72
209
|
clarifyTimeoutError?: boolean;
|
73
210
|
}
|
74
211
|
|
212
|
+
export interface GenericAbortSignal {
|
213
|
+
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 ParamsSerializerOptions extends SerializerOptions {
|
251
|
+
encode?: ParamEncoder;
|
252
|
+
}
|
253
|
+
|
254
|
+
type MaxUploadRate = number;
|
255
|
+
|
256
|
+
type MaxDownloadRate = number;
|
257
|
+
|
258
|
+
export interface AxiosProgressEvent {
|
259
|
+
loaded: number;
|
260
|
+
total?: number;
|
261
|
+
progress?: number;
|
262
|
+
bytes: number;
|
263
|
+
rate?: number;
|
264
|
+
estimated?: number;
|
265
|
+
upload?: boolean;
|
266
|
+
download?: boolean;
|
267
|
+
}
|
268
|
+
|
269
|
+
type Milliseconds = number;
|
270
|
+
|
75
271
|
export interface AxiosRequestConfig<D = any> {
|
76
272
|
url?: string;
|
77
273
|
method?: Method | string;
|
78
274
|
baseURL?: string;
|
79
275
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
80
276
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
81
|
-
headers?:
|
277
|
+
headers?: RawAxiosRequestHeaders;
|
82
278
|
params?: any;
|
83
|
-
paramsSerializer?:
|
279
|
+
paramsSerializer?: ParamsSerializerOptions;
|
84
280
|
data?: D;
|
85
|
-
timeout?:
|
281
|
+
timeout?: Milliseconds;
|
86
282
|
timeoutErrorMessage?: string;
|
87
283
|
withCredentials?: boolean;
|
88
284
|
adapter?: AxiosAdapter;
|
@@ -91,12 +287,13 @@ export interface AxiosRequestConfig<D = any> {
|
|
91
287
|
responseEncoding?: responseEncoding | string;
|
92
288
|
xsrfCookieName?: string;
|
93
289
|
xsrfHeaderName?: string;
|
94
|
-
onUploadProgress?: (progressEvent:
|
95
|
-
onDownloadProgress?: (progressEvent:
|
290
|
+
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
291
|
+
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
96
292
|
maxContentLength?: number;
|
97
293
|
validateStatus?: ((status: number) => boolean) | null;
|
98
294
|
maxBodyLength?: number;
|
99
295
|
maxRedirects?: number;
|
296
|
+
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
100
297
|
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
|
101
298
|
socketPath?: string | null;
|
102
299
|
httpAgent?: any;
|
@@ -105,56 +302,62 @@ export interface AxiosRequestConfig<D = any> {
|
|
105
302
|
cancelToken?: CancelToken;
|
106
303
|
decompress?: boolean;
|
107
304
|
transitional?: TransitionalOptions;
|
108
|
-
signal?:
|
305
|
+
signal?: GenericAbortSignal;
|
109
306
|
insecureHTTPParser?: boolean;
|
110
307
|
env?: {
|
111
308
|
FormData?: new (...args: any[]) => object;
|
112
309
|
};
|
310
|
+
formSerializer?: FormSerializerOptions;
|
113
311
|
}
|
114
312
|
|
115
313
|
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?:
|
314
|
+
common: RawAxiosRequestHeaders;
|
315
|
+
delete: RawAxiosRequestHeaders;
|
316
|
+
get: RawAxiosRequestHeaders;
|
317
|
+
head: RawAxiosRequestHeaders;
|
318
|
+
post: RawAxiosRequestHeaders;
|
319
|
+
put: RawAxiosRequestHeaders;
|
320
|
+
patch: RawAxiosRequestHeaders;
|
321
|
+
options?: RawAxiosRequestHeaders;
|
322
|
+
purge?: RawAxiosRequestHeaders;
|
323
|
+
link?: RawAxiosRequestHeaders;
|
324
|
+
unlink?: RawAxiosRequestHeaders;
|
127
325
|
}
|
128
326
|
|
129
327
|
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
130
328
|
headers: HeadersDefaults;
|
131
329
|
}
|
132
330
|
|
331
|
+
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
332
|
+
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
333
|
+
}
|
334
|
+
|
133
335
|
export interface AxiosResponse<T = any, D = any> {
|
134
336
|
data: T;
|
135
337
|
status: number;
|
136
338
|
statusText: string;
|
137
|
-
headers: AxiosResponseHeaders;
|
339
|
+
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
138
340
|
config: AxiosRequestConfig<D>;
|
139
341
|
request?: any;
|
140
342
|
}
|
141
343
|
|
142
344
|
export class AxiosError<T = unknown, D = any> extends Error {
|
143
345
|
constructor(
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
346
|
+
message?: string,
|
347
|
+
code?: string,
|
348
|
+
config?: AxiosRequestConfig<D>,
|
349
|
+
request?: any,
|
350
|
+
response?: AxiosResponse<T, D>
|
149
351
|
);
|
150
352
|
|
151
|
-
config
|
353
|
+
config?: AxiosRequestConfig<D>;
|
152
354
|
code?: string;
|
153
355
|
request?: any;
|
154
356
|
response?: AxiosResponse<T, D>;
|
155
357
|
isAxiosError: boolean;
|
156
|
-
status?:
|
358
|
+
status?: number;
|
157
359
|
toJSON: () => object;
|
360
|
+
cause?: Error;
|
158
361
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
159
362
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
160
363
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
@@ -162,6 +365,8 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
162
365
|
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
163
366
|
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
164
367
|
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
368
|
+
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
369
|
+
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
165
370
|
static readonly ERR_CANCELED = "ERR_CANCELED";
|
166
371
|
static readonly ECONNABORTED = "ECONNABORTED";
|
167
372
|
static readonly ETIMEDOUT = "ETIMEDOUT";
|
@@ -170,8 +375,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
170
375
|
export class CanceledError<T> extends AxiosError<T> {
|
171
376
|
}
|
172
377
|
|
173
|
-
export
|
174
|
-
}
|
378
|
+
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
175
379
|
|
176
380
|
export interface CancelStatic {
|
177
381
|
new (message?: string): Cancel;
|
@@ -182,7 +386,7 @@ export interface Cancel {
|
|
182
386
|
}
|
183
387
|
|
184
388
|
export interface Canceler {
|
185
|
-
(message?: string): void;
|
389
|
+
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
186
390
|
}
|
187
391
|
|
188
392
|
export interface CancelTokenStatic {
|
@@ -207,7 +411,7 @@ export interface AxiosInterceptorOptions {
|
|
207
411
|
}
|
208
412
|
|
209
413
|
export interface AxiosInterceptorManager<V> {
|
210
|
-
use
|
414
|
+
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
|
211
415
|
eject(id: number): void;
|
212
416
|
}
|
213
417
|
|
@@ -233,20 +437,39 @@ export class Axios {
|
|
233
437
|
}
|
234
438
|
|
235
439
|
export interface AxiosInstance extends Axios {
|
236
|
-
(config: AxiosRequestConfig):
|
237
|
-
(url: string, config?: AxiosRequestConfig):
|
440
|
+
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
441
|
+
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
442
|
+
|
443
|
+
defaults: Omit<AxiosDefaults, 'headers'> & {
|
444
|
+
headers: HeadersDefaults & {
|
445
|
+
[key: string]: AxiosHeaderValue
|
446
|
+
}
|
447
|
+
};
|
448
|
+
}
|
449
|
+
|
450
|
+
export interface GenericFormData {
|
451
|
+
append(name: string, value: any, options?: any): any;
|
452
|
+
}
|
453
|
+
|
454
|
+
export interface GenericHTMLFormElement {
|
455
|
+
name: string;
|
456
|
+
method: string;
|
457
|
+
submit(): void;
|
238
458
|
}
|
239
459
|
|
240
460
|
export interface AxiosStatic extends AxiosInstance {
|
241
|
-
create(config?:
|
461
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
242
462
|
Cancel: CancelStatic;
|
243
463
|
CancelToken: CancelTokenStatic;
|
244
464
|
Axios: typeof Axios;
|
465
|
+
AxiosError: typeof AxiosError;
|
245
466
|
readonly VERSION: string;
|
246
|
-
isCancel(value: any):
|
467
|
+
isCancel(value: any): value is Cancel;
|
247
468
|
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
248
469
|
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
249
|
-
isAxiosError(payload: any): payload is AxiosError
|
470
|
+
isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
471
|
+
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
472
|
+
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
250
473
|
}
|
251
474
|
|
252
475
|
declare const axios: AxiosStatic;
|
package/index.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import axios from './lib/axios.js';
|
2
|
+
export default axios;
|