axios 1.8.4 → 1.10.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.
- package/CHANGELOG.md +51 -0
- package/README.md +24 -21
- package/dist/axios.js +36 -17
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +36 -14
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +36 -14
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +37 -15
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +3 -3
- package/index.d.ts +5 -3
- package/lib/adapters/fetch.js +2 -2
- package/lib/core/Axios.js +1 -1
- package/lib/core/AxiosHeaders.js +15 -3
- package/lib/env/data.js +1 -1
- package/lib/helpers/formDataToStream.js +1 -1
- package/lib/helpers/toFormData.js +4 -0
- package/lib/utils.js +12 -6
- package/package.json +13 -4
package/index.d.cts
CHANGED
|
@@ -359,7 +359,7 @@ declare namespace axios {
|
|
|
359
359
|
|
|
360
360
|
type Milliseconds = number;
|
|
361
361
|
|
|
362
|
-
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
|
|
362
|
+
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
|
|
363
363
|
|
|
364
364
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
|
365
365
|
|
|
@@ -418,7 +418,7 @@ declare namespace axios {
|
|
|
418
418
|
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
|
419
419
|
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
|
420
420
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
421
|
-
fetchOptions?: Record<string, any>;
|
|
421
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
// Alias
|
|
@@ -508,6 +508,7 @@ declare namespace axios {
|
|
|
508
508
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
509
509
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
510
510
|
|
|
511
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
511
512
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
|
512
513
|
headers: HeadersDefaults & {
|
|
513
514
|
[key: string]: AxiosHeaderValue
|
|
@@ -526,7 +527,6 @@ declare namespace axios {
|
|
|
526
527
|
}
|
|
527
528
|
|
|
528
529
|
interface AxiosStatic extends AxiosInstance {
|
|
529
|
-
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
530
530
|
Cancel: CancelStatic;
|
|
531
531
|
CancelToken: CancelTokenStatic;
|
|
532
532
|
Axios: typeof Axios;
|
package/index.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ export class AxiosHeaders {
|
|
|
74
74
|
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
|
75
75
|
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
|
76
76
|
|
|
77
|
+
getSetCookie(): string[];
|
|
78
|
+
|
|
77
79
|
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -300,7 +302,7 @@ export interface AxiosProgressEvent {
|
|
|
300
302
|
|
|
301
303
|
type Milliseconds = number;
|
|
302
304
|
|
|
303
|
-
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
|
|
305
|
+
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
|
|
304
306
|
|
|
305
307
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
|
306
308
|
|
|
@@ -359,7 +361,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
359
361
|
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
|
360
362
|
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
|
361
363
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
362
|
-
fetchOptions?: Record<string, any>;
|
|
364
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
|
363
365
|
}
|
|
364
366
|
|
|
365
367
|
// Alias
|
|
@@ -512,6 +514,7 @@ export interface AxiosInstance extends Axios {
|
|
|
512
514
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
513
515
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
514
516
|
|
|
517
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
515
518
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
|
516
519
|
headers: HeadersDefaults & {
|
|
517
520
|
[key: string]: AxiosHeaderValue
|
|
@@ -546,7 +549,6 @@ export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
|
|
546
549
|
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
|
547
550
|
|
|
548
551
|
export interface AxiosStatic extends AxiosInstance {
|
|
549
|
-
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
550
552
|
Cancel: CancelStatic;
|
|
551
553
|
CancelToken: CancelTokenStatic;
|
|
552
554
|
Axios: typeof Axios;
|
package/lib/adapters/fetch.js
CHANGED
|
@@ -167,7 +167,7 @@ export default isFetchSupported && (async (config) => {
|
|
|
167
167
|
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
let response = await fetch(request);
|
|
170
|
+
let response = await fetch(request, fetchOptions);
|
|
171
171
|
|
|
172
172
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
173
173
|
|
|
@@ -213,7 +213,7 @@ export default isFetchSupported && (async (config) => {
|
|
|
213
213
|
} catch (err) {
|
|
214
214
|
unsubscribe && unsubscribe();
|
|
215
215
|
|
|
216
|
-
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
216
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
217
217
|
throw Object.assign(
|
|
218
218
|
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
219
219
|
{
|
package/lib/core/Axios.js
CHANGED
|
@@ -20,7 +20,7 @@ const validators = validator.validators;
|
|
|
20
20
|
*/
|
|
21
21
|
class Axios {
|
|
22
22
|
constructor(instanceConfig) {
|
|
23
|
-
this.defaults = instanceConfig;
|
|
23
|
+
this.defaults = instanceConfig || {};
|
|
24
24
|
this.interceptors = {
|
|
25
25
|
request: new InterceptorManager(),
|
|
26
26
|
response: new InterceptorManager()
|
package/lib/core/AxiosHeaders.js
CHANGED
|
@@ -100,10 +100,18 @@ class AxiosHeaders {
|
|
|
100
100
|
setHeaders(header, valueOrRewrite)
|
|
101
101
|
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
102
102
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
103
|
-
} else if (utils.
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
} else if (utils.isObject(header) && utils.isIterable(header)) {
|
|
104
|
+
let obj = {}, dest, key;
|
|
105
|
+
for (const entry of header) {
|
|
106
|
+
if (!utils.isArray(entry)) {
|
|
107
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
obj[key = entry[0]] = (dest = obj[key]) ?
|
|
111
|
+
(utils.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
|
|
106
112
|
}
|
|
113
|
+
|
|
114
|
+
setHeaders(obj, valueOrRewrite)
|
|
107
115
|
} else {
|
|
108
116
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
109
117
|
}
|
|
@@ -245,6 +253,10 @@ class AxiosHeaders {
|
|
|
245
253
|
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
|
246
254
|
}
|
|
247
255
|
|
|
256
|
+
getSetCookie() {
|
|
257
|
+
return this.get("set-cookie") || [];
|
|
258
|
+
}
|
|
259
|
+
|
|
248
260
|
get [Symbol.toStringTag]() {
|
|
249
261
|
return 'AxiosHeaders';
|
|
250
262
|
}
|
package/lib/env/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.10.0";
|
|
@@ -76,7 +76,7 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
|
79
|
-
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF
|
|
79
|
+
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
|
|
80
80
|
let contentLength = footerBytes.byteLength;
|
|
81
81
|
|
|
82
82
|
const parts = Array.from(form.entries()).map(([name, value]) => {
|
|
@@ -120,6 +120,10 @@ function toFormData(obj, formData, options) {
|
|
|
120
120
|
return value.toISOString();
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
if (utils.isBoolean(value)) {
|
|
124
|
+
return value.toString();
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
if (!useBlob && utils.isBlob(value)) {
|
|
124
128
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
125
129
|
}
|
package/lib/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ import bind from './helpers/bind.js';
|
|
|
6
6
|
|
|
7
7
|
const {toString} = Object.prototype;
|
|
8
8
|
const {getPrototypeOf} = Object;
|
|
9
|
+
const {iterator, toStringTag} = Symbol;
|
|
9
10
|
|
|
10
11
|
const kindOf = (cache => thing => {
|
|
11
12
|
const str = toString.call(thing);
|
|
@@ -132,7 +133,7 @@ const isPlainObject = (val) => {
|
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
const prototype = getPrototypeOf(val);
|
|
135
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(
|
|
136
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
/**
|
|
@@ -483,13 +484,13 @@ const isTypedArray = (TypedArray => {
|
|
|
483
484
|
* @returns {void}
|
|
484
485
|
*/
|
|
485
486
|
const forEachEntry = (obj, fn) => {
|
|
486
|
-
const generator = obj && obj[
|
|
487
|
+
const generator = obj && obj[iterator];
|
|
487
488
|
|
|
488
|
-
const
|
|
489
|
+
const _iterator = generator.call(obj);
|
|
489
490
|
|
|
490
491
|
let result;
|
|
491
492
|
|
|
492
|
-
while ((result =
|
|
493
|
+
while ((result = _iterator.next()) && !result.done) {
|
|
493
494
|
const pair = result.value;
|
|
494
495
|
fn.call(obj, pair[0], pair[1]);
|
|
495
496
|
}
|
|
@@ -610,7 +611,7 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
610
611
|
* @returns {boolean}
|
|
611
612
|
*/
|
|
612
613
|
function isSpecCompliantForm(thing) {
|
|
613
|
-
return !!(thing && isFunction(thing.append) && thing[
|
|
614
|
+
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
614
615
|
}
|
|
615
616
|
|
|
616
617
|
const toJSONObject = (obj) => {
|
|
@@ -679,6 +680,10 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
679
680
|
|
|
680
681
|
// *********************
|
|
681
682
|
|
|
683
|
+
|
|
684
|
+
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
685
|
+
|
|
686
|
+
|
|
682
687
|
export default {
|
|
683
688
|
isArray,
|
|
684
689
|
isArrayBuffer,
|
|
@@ -734,5 +739,6 @@ export default {
|
|
|
734
739
|
isAsyncFn,
|
|
735
740
|
isThenable,
|
|
736
741
|
setImmediate: _setImmediate,
|
|
737
|
-
asap
|
|
742
|
+
asap,
|
|
743
|
+
isIterable
|
|
738
744
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"require": "./index.d.cts",
|
|
10
10
|
"default": "./index.d.ts"
|
|
11
11
|
},
|
|
12
|
+
"react-native": {
|
|
13
|
+
"require": "./dist/browser/axios.cjs",
|
|
14
|
+
"default": "./dist/esm/axios.js"
|
|
15
|
+
},
|
|
12
16
|
"browser": {
|
|
13
17
|
"require": "./dist/browser/axios.cjs",
|
|
14
18
|
"default": "./index.js"
|
|
@@ -143,6 +147,11 @@
|
|
|
143
147
|
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
|
|
144
148
|
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
|
|
145
149
|
},
|
|
150
|
+
"react-native": {
|
|
151
|
+
"./lib/adapters/http.js": "./lib/helpers/null.js",
|
|
152
|
+
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
|
|
153
|
+
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
|
|
154
|
+
},
|
|
146
155
|
"jsdelivr": "dist/axios.min.js",
|
|
147
156
|
"unpkg": "dist/axios.min.js",
|
|
148
157
|
"typings": "./index.d.ts",
|
|
@@ -167,10 +176,10 @@
|
|
|
167
176
|
"Justin Beckwith (https://github.com/JustinBeckwith)",
|
|
168
177
|
"Martti Laine (https://github.com/codeclown)",
|
|
169
178
|
"Xianming Zhong (https://github.com/chinesedfan)",
|
|
170
|
-
"Remco Haszing (https://github.com/remcohaszing)",
|
|
171
179
|
"Rikki Gibson (https://github.com/RikkiGibson)",
|
|
172
|
-
"
|
|
173
|
-
"Yasu Flores (https://github.com/yasuf)"
|
|
180
|
+
"Remco Haszing (https://github.com/remcohaszing)",
|
|
181
|
+
"Yasu Flores (https://github.com/yasuf)",
|
|
182
|
+
"Ben Carp (https://github.com/carpben)"
|
|
174
183
|
],
|
|
175
184
|
"sideEffects": false,
|
|
176
185
|
"release-it": {
|