axios 1.5.0 → 1.6.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 +181 -0
- package/README.md +268 -7
- package/dist/axios.js +36 -15
- 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 +45 -22
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +45 -22
- 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 +70 -34
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +19 -11
- package/index.d.ts +20 -12
- package/lib/adapters/adapters.js +33 -15
- package/lib/adapters/http.js +25 -12
- package/lib/adapters/xhr.js +9 -4
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,53 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# [1.6.0](https://github.com/axios/axios/compare/v1.5.1...v1.6.0) (2023-10-26)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* **CSRF:** fixed CSRF vulnerability CVE-2023-45857 ([#6028](https://github.com/axios/axios/issues/6028)) ([96ee232](https://github.com/axios/axios/commit/96ee232bd3ee4de2e657333d4d2191cd389e14d0))
|
9
|
+
* **dns:** fixed lookup function decorator to work properly in node v20; ([#6011](https://github.com/axios/axios/issues/6011)) ([5aaff53](https://github.com/axios/axios/commit/5aaff532a6b820bb9ab6a8cd0f77131b47e2adb8))
|
10
|
+
* **types:** fix AxiosHeaders types; ([#5931](https://github.com/axios/axios/issues/5931)) ([a1c8ad0](https://github.com/axios/axios/commit/a1c8ad008b3c13d53e135bbd0862587fb9d3fc09))
|
11
|
+
|
12
|
+
### PRs
|
13
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
14
|
+
```
|
15
|
+
|
16
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
17
|
+
```
|
18
|
+
|
19
|
+
### Contributors to this release
|
20
|
+
|
21
|
+
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+449/-114 (#6032 #6021 #6011 #5932 #5931 )")
|
22
|
+
- <img src="https://avatars.githubusercontent.com/u/63700910?v=4&s=18" alt="avatar" width="18"/> [Valentin Panov](https://github.com/valentin-panov "+4/-4 (#6028 )")
|
23
|
+
- <img src="https://avatars.githubusercontent.com/u/76877078?v=4&s=18" alt="avatar" width="18"/> [Rinku Chaudhari](https://github.com/therealrinku "+1/-1 (#5889 )")
|
24
|
+
|
25
|
+
## [1.5.1](https://github.com/axios/axios/compare/v1.5.0...v1.5.1) (2023-09-26)
|
26
|
+
|
27
|
+
|
28
|
+
### Bug Fixes
|
29
|
+
|
30
|
+
* **adapters:** improved adapters loading logic to have clear error messages; ([#5919](https://github.com/axios/axios/issues/5919)) ([e410779](https://github.com/axios/axios/commit/e4107797a7a1376f6209fbecfbbce73d3faa7859))
|
31
|
+
* **formdata:** fixed automatic addition of the `Content-Type` header for FormData in non-browser environments; ([#5917](https://github.com/axios/axios/issues/5917)) ([bc9af51](https://github.com/axios/axios/commit/bc9af51b1886d1b3529617702f2a21a6c0ed5d92))
|
32
|
+
* **headers:** allow `content-encoding` header to handle case-insensitive values ([#5890](https://github.com/axios/axios/issues/5890)) ([#5892](https://github.com/axios/axios/issues/5892)) ([4c89f25](https://github.com/axios/axios/commit/4c89f25196525e90a6e75eda9cb31ae0a2e18acd))
|
33
|
+
* **types:** removed duplicated code ([9e62056](https://github.com/axios/axios/commit/9e6205630e1c9cf863adf141c0edb9e6d8d4b149))
|
34
|
+
|
35
|
+
### Contributors to this release
|
36
|
+
|
37
|
+
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+89/-18 (#5919 #5917 )")
|
38
|
+
- <img src="https://avatars.githubusercontent.com/u/110460234?v=4&s=18" alt="avatar" width="18"/> [David Dallas](https://github.com/DavidJDallas "+11/-5 ()")
|
39
|
+
- <img src="https://avatars.githubusercontent.com/u/71556073?v=4&s=18" alt="avatar" width="18"/> [Sean Sattler](https://github.com/fb-sean "+2/-8 ()")
|
40
|
+
- <img src="https://avatars.githubusercontent.com/u/4294069?v=4&s=18" alt="avatar" width="18"/> [Mustafa Ateş Uzun](https://github.com/0o001 "+4/-4 ()")
|
41
|
+
- <img src="https://avatars.githubusercontent.com/u/132928043?v=4&s=18" alt="avatar" width="18"/> [Przemyslaw Motacki](https://github.com/sfc-gh-pmotacki "+2/-1 (#5892 )")
|
42
|
+
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+1/-1 ()")
|
43
|
+
|
44
|
+
### PRs
|
45
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
46
|
+
```
|
47
|
+
|
48
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
49
|
+
```
|
50
|
+
|
3
51
|
# [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26)
|
4
52
|
|
5
53
|
|
@@ -23,6 +71,13 @@
|
|
23
71
|
- <img src="https://avatars.githubusercontent.com/u/65978976?v=4&s=18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )")
|
24
72
|
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )")
|
25
73
|
|
74
|
+
### PRs
|
75
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
76
|
+
```
|
77
|
+
|
78
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
79
|
+
```
|
80
|
+
|
26
81
|
# [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27)
|
27
82
|
|
28
83
|
|
@@ -48,6 +103,13 @@
|
|
48
103
|
- <img src="https://avatars.githubusercontent.com/u/47537704?v=4&s=18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )")
|
49
104
|
- <img src="https://avatars.githubusercontent.com/u/43876655?v=4&s=18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )")
|
50
105
|
|
106
|
+
### PRs
|
107
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
108
|
+
```
|
109
|
+
|
110
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
111
|
+
```
|
112
|
+
|
51
113
|
## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19)
|
52
114
|
|
53
115
|
|
@@ -61,6 +123,13 @@
|
|
61
123
|
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+48/-10 (#5665 #5661 #5663 )")
|
62
124
|
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+2/-0 (#5445 )")
|
63
125
|
|
126
|
+
### PRs
|
127
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
128
|
+
```
|
129
|
+
|
130
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
131
|
+
```
|
132
|
+
|
64
133
|
## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05)
|
65
134
|
|
66
135
|
|
@@ -73,6 +142,13 @@
|
|
73
142
|
|
74
143
|
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+28/-10 (#5633 #5584 )")
|
75
144
|
|
145
|
+
### PRs
|
146
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
147
|
+
```
|
148
|
+
|
149
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
150
|
+
```
|
151
|
+
|
76
152
|
## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22)
|
77
153
|
|
78
154
|
|
@@ -87,6 +163,13 @@
|
|
87
163
|
- <img src="https://avatars.githubusercontent.com/u/19550000?v=4&s=18" alt="avatar" width="18"/> [lcysgsg](https://github.com/lcysgsg "+4/-0 (#5548 )")
|
88
164
|
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-0 (#5444 )")
|
89
165
|
|
166
|
+
### PRs
|
167
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
168
|
+
```
|
169
|
+
|
170
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
171
|
+
```
|
172
|
+
|
90
173
|
## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13)
|
91
174
|
|
92
175
|
|
@@ -101,6 +184,13 @@
|
|
101
184
|
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+11/-7 (#5545 #5535 #5542 )")
|
102
185
|
- <img src="https://avatars.githubusercontent.com/u/19842213?v=4&s=18" alt="avatar" width="18"/> [陈若枫](https://github.com/ruofee "+2/-2 (#5467 )")
|
103
186
|
|
187
|
+
### PRs
|
188
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
189
|
+
```
|
190
|
+
|
191
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
192
|
+
```
|
193
|
+
|
104
194
|
## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03)
|
105
195
|
|
106
196
|
|
@@ -113,6 +203,13 @@
|
|
113
203
|
|
114
204
|
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+2/-1 (#5530 #5528 )")
|
115
205
|
|
206
|
+
### PRs
|
207
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
208
|
+
```
|
209
|
+
|
210
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
211
|
+
```
|
212
|
+
|
116
213
|
## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01)
|
117
214
|
|
118
215
|
|
@@ -125,6 +222,13 @@
|
|
125
222
|
|
126
223
|
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )")
|
127
224
|
|
225
|
+
### PRs
|
226
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
227
|
+
```
|
228
|
+
|
229
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
230
|
+
```
|
231
|
+
|
128
232
|
# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31)
|
129
233
|
|
130
234
|
|
@@ -143,6 +247,13 @@
|
|
143
247
|
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )")
|
144
248
|
- <img src="https://avatars.githubusercontent.com/u/35015993?v=4&s=18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )")
|
145
249
|
|
250
|
+
### PRs
|
251
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
252
|
+
```
|
253
|
+
|
254
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
255
|
+
```
|
256
|
+
|
146
257
|
## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28)
|
147
258
|
|
148
259
|
|
@@ -155,6 +266,13 @@
|
|
155
266
|
|
156
267
|
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )")
|
157
268
|
|
269
|
+
### PRs
|
270
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
271
|
+
```
|
272
|
+
|
273
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
274
|
+
```
|
275
|
+
|
158
276
|
## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26)
|
159
277
|
|
160
278
|
|
@@ -167,6 +285,13 @@
|
|
167
285
|
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+82/-54 (#5499 )")
|
168
286
|
-  [Elliot Ford](https://github.com/EFord36 "+1/-1 (#5462 )")
|
169
287
|
|
288
|
+
### PRs
|
289
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
290
|
+
```
|
291
|
+
|
292
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
293
|
+
```
|
294
|
+
|
170
295
|
## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22)
|
171
296
|
|
172
297
|
|
@@ -180,6 +305,13 @@
|
|
180
305
|
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+242/-108 (#5486 #5482 )")
|
181
306
|
-  [Daniel Hillmann](https://github.com/hilleer "+1/-1 (#5478 )")
|
182
307
|
|
308
|
+
### PRs
|
309
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
310
|
+
```
|
311
|
+
|
312
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
313
|
+
```
|
314
|
+
|
183
315
|
## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10)
|
184
316
|
|
185
317
|
|
@@ -191,6 +323,13 @@
|
|
191
323
|
|
192
324
|
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+938/-442 (#5456 #5455 #5453 #5451 #5449 #5447 #5446 #5443 #5442 #5439 #5420 )")
|
193
325
|
|
326
|
+
### PRs
|
327
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
328
|
+
```
|
329
|
+
|
330
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
331
|
+
```
|
332
|
+
|
194
333
|
## [1.2.2] - 2022-12-29
|
195
334
|
|
196
335
|
### Fixed
|
@@ -245,6 +384,13 @@
|
|
245
384
|
- [Ivan Barsukov](https://github.com/ovarn)
|
246
385
|
- [Arthur Fiorette](https://github.com/arthurfiorette)
|
247
386
|
|
387
|
+
### PRs
|
388
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
389
|
+
```
|
390
|
+
|
391
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
392
|
+
```
|
393
|
+
|
248
394
|
## [1.2.0] - 2022-11-10
|
249
395
|
|
250
396
|
### Changed
|
@@ -311,6 +457,13 @@
|
|
311
457
|
- [AZM](https://github.com/aziyatali)
|
312
458
|
- [relbns](https://github.com/relbns)
|
313
459
|
|
460
|
+
### PRs
|
461
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
462
|
+
```
|
463
|
+
|
464
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
465
|
+
```
|
466
|
+
|
314
467
|
## [1.1.3] - 2022-10-15
|
315
468
|
|
316
469
|
### Added
|
@@ -345,6 +498,13 @@
|
|
345
498
|
- [littledian](https://github.com/littledian)
|
346
499
|
- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime)
|
347
500
|
|
501
|
+
### PRs
|
502
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
503
|
+
```
|
504
|
+
|
505
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
506
|
+
```
|
507
|
+
|
348
508
|
## [1.1.2] - 2022-10-07
|
349
509
|
|
350
510
|
### Fixed
|
@@ -355,6 +515,13 @@
|
|
355
515
|
|
356
516
|
- [Jason Saayman](https://github.com/jasonsaayman)
|
357
517
|
|
518
|
+
### PRs
|
519
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
520
|
+
```
|
521
|
+
|
522
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
523
|
+
```
|
524
|
+
|
358
525
|
## [1.1.1] - 2022-10-07
|
359
526
|
|
360
527
|
### Fixed
|
@@ -365,6 +532,13 @@
|
|
365
532
|
|
366
533
|
- [Jason Saayman](https://github.com/jasonsaayman)
|
367
534
|
|
535
|
+
### PRs
|
536
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
537
|
+
```
|
538
|
+
|
539
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
540
|
+
```
|
541
|
+
|
368
542
|
## [1.1.0] - 2022-10-06
|
369
543
|
|
370
544
|
### Fixed
|
@@ -384,6 +558,13 @@
|
|
384
558
|
- [Ivan Pepelko](https://github.com/ivanpepelko)
|
385
559
|
- [Richard Kořínek](https://github.com/risa)
|
386
560
|
|
561
|
+
### PRs
|
562
|
+
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
|
563
|
+
```
|
564
|
+
|
565
|
+
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
|
566
|
+
```
|
567
|
+
|
387
568
|
## [1.0.0] - 2022-10-04
|
388
569
|
|
389
570
|
### Added
|
package/README.md
CHANGED
@@ -66,6 +66,7 @@
|
|
66
66
|
- [HTML Form Posting](#-html-form-posting-browser)
|
67
67
|
- [🆕 Progress capturing](#-progress-capturing)
|
68
68
|
- [🆕 Rate limiting](#-progress-capturing)
|
69
|
+
- [🆕 AxiosHeaders](#-axiosheaders)
|
69
70
|
- [Semver](#semver)
|
70
71
|
- [Promises](#promises)
|
71
72
|
- [TypeScript](#typescript)
|
@@ -167,7 +168,7 @@ Using unpkg CDN:
|
|
167
168
|
|
168
169
|
## Example
|
169
170
|
|
170
|
-
> **Note
|
171
|
+
> **Note**: CommonJS usage
|
171
172
|
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach:
|
172
173
|
|
173
174
|
```js
|
@@ -384,12 +385,18 @@ These are the available config options for making requests. Only the `url` is re
|
|
384
385
|
params: {
|
385
386
|
ID: 12345
|
386
387
|
},
|
387
|
-
|
388
|
-
// `paramsSerializer` is an optional config
|
388
|
+
|
389
|
+
// `paramsSerializer` is an optional config that allows you to customize serializing `params`.
|
389
390
|
paramsSerializer: {
|
390
|
-
|
391
|
-
|
392
|
-
|
391
|
+
|
392
|
+
//Custom encoder function which sends key/value pairs in an iterative fashion.
|
393
|
+
encode?: (param: string): string => { /* Do custom operations here and return transformed string */ },
|
394
|
+
|
395
|
+
// Custom serializer function for the entire parameter. Allows user to mimic pre 1.x behaviour.
|
396
|
+
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ),
|
397
|
+
|
398
|
+
//Configuration for formatting array indexes in the params.
|
399
|
+
indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes).
|
393
400
|
},
|
394
401
|
|
395
402
|
// `data` is the data to be sent as the request body
|
@@ -1264,7 +1271,7 @@ const {data} = await axios.post(SERVER_URL, readableStream, {
|
|
1264
1271
|
````
|
1265
1272
|
|
1266
1273
|
> **Note:**
|
1267
|
-
> Capturing FormData upload progress is
|
1274
|
+
> Capturing FormData upload progress is not currently supported in node.js environments.
|
1268
1275
|
|
1269
1276
|
> **⚠️ Warning**
|
1270
1277
|
> It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment,
|
@@ -1285,6 +1292,260 @@ const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, {
|
|
1285
1292
|
});
|
1286
1293
|
```
|
1287
1294
|
|
1295
|
+
## 🆕 AxiosHeaders
|
1296
|
+
|
1297
|
+
Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work.
|
1298
|
+
Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons
|
1299
|
+
and for a workaround when servers mistakenly consider the header's case.
|
1300
|
+
The old approach of directly manipulating headers object is still available, but deprecated and not recommended for future usage.
|
1301
|
+
|
1302
|
+
### Working with headers
|
1303
|
+
|
1304
|
+
An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic.
|
1305
|
+
The final headers object with string values is obtained by Axios by calling the `toJSON` method.
|
1306
|
+
|
1307
|
+
> Note: By JSON here we mean an object consisting only of string values intended to be sent over the network.
|
1308
|
+
|
1309
|
+
The header value can be one of the following types:
|
1310
|
+
- `string` - normal string value that will be sent to the server
|
1311
|
+
- `null` - skip header when rendering to JSON
|
1312
|
+
- `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true`
|
1313
|
+
to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`)
|
1314
|
+
- `undefined` - value is not set
|
1315
|
+
|
1316
|
+
> Note: The header value is considered set if it is not equal to undefined.
|
1317
|
+
|
1318
|
+
The headers object is always initialized inside interceptors and transformers:
|
1319
|
+
|
1320
|
+
```ts
|
1321
|
+
axios.interceptors.request.use((request: InternalAxiosRequestConfig) => {
|
1322
|
+
request.headers.set('My-header', 'value');
|
1323
|
+
|
1324
|
+
request.headers.set({
|
1325
|
+
"My-set-header1": "my-set-value1",
|
1326
|
+
"My-set-header2": "my-set-value2"
|
1327
|
+
});
|
1328
|
+
|
1329
|
+
request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios
|
1330
|
+
|
1331
|
+
request.headers.setContentType('text/plain');
|
1332
|
+
|
1333
|
+
request.headers['My-set-header2'] = 'newValue' // direct access is deprecated
|
1334
|
+
|
1335
|
+
return request;
|
1336
|
+
}
|
1337
|
+
);
|
1338
|
+
````
|
1339
|
+
|
1340
|
+
You can iterate over an `AxiosHeaders` instance using a `for...of` statement:
|
1341
|
+
|
1342
|
+
````js
|
1343
|
+
const headers = new AxiosHeaders({
|
1344
|
+
foo: '1',
|
1345
|
+
bar: '2',
|
1346
|
+
baz: '3'
|
1347
|
+
});
|
1348
|
+
|
1349
|
+
for(const [header, value] of headers) {
|
1350
|
+
console.log(header, value);
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
// foo 1
|
1354
|
+
// bar 2
|
1355
|
+
// baz 3
|
1356
|
+
````
|
1357
|
+
|
1358
|
+
### new AxiosHeaders(headers?)
|
1359
|
+
|
1360
|
+
Constructs a new `AxiosHeaders` instance.
|
1361
|
+
|
1362
|
+
```
|
1363
|
+
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
|
1364
|
+
```
|
1365
|
+
|
1366
|
+
If the headers object is a string, it will be parsed as RAW HTTP headers.
|
1367
|
+
|
1368
|
+
````js
|
1369
|
+
const headers = new AxiosHeaders(`
|
1370
|
+
Host: www.bing.com
|
1371
|
+
User-Agent: curl/7.54.0
|
1372
|
+
Accept: */*`);
|
1373
|
+
|
1374
|
+
console.log(headers);
|
1375
|
+
|
1376
|
+
// Object [AxiosHeaders] {
|
1377
|
+
// host: 'www.bing.com',
|
1378
|
+
// 'user-agent': 'curl/7.54.0',
|
1379
|
+
// accept: '*/*'
|
1380
|
+
// }
|
1381
|
+
````
|
1382
|
+
|
1383
|
+
### AxiosHeaders#set
|
1384
|
+
|
1385
|
+
```ts
|
1386
|
+
set(headerName, value: Axios, rewrite?: boolean);
|
1387
|
+
set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean);
|
1388
|
+
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean);
|
1389
|
+
```
|
1390
|
+
|
1391
|
+
The `rewrite` argument controls the overwriting behavior:
|
1392
|
+
- `false` - do not overwrite if header's value is set (is not `undefined`)
|
1393
|
+
- `undefined` (default) - overwrite the header unless its value is set to `false`
|
1394
|
+
- `true` - rewrite anyway
|
1395
|
+
|
1396
|
+
The option can also accept a user-defined function that determines whether the value should be overwritten or not.
|
1397
|
+
|
1398
|
+
Returns `this`.
|
1399
|
+
|
1400
|
+
### AxiosHeaders#get(header)
|
1401
|
+
|
1402
|
+
```
|
1403
|
+
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
|
1404
|
+
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
1405
|
+
````
|
1406
|
+
|
1407
|
+
Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`,
|
1408
|
+
matcher function or internal key-value parser.
|
1409
|
+
|
1410
|
+
```ts
|
1411
|
+
const headers = new AxiosHeaders({
|
1412
|
+
'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h'
|
1413
|
+
});
|
1414
|
+
|
1415
|
+
console.log(headers.get('Content-Type'));
|
1416
|
+
// multipart/form-data; boundary=Asrf456BGe4h
|
1417
|
+
|
1418
|
+
console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters:
|
1419
|
+
// [Object: null prototype] {
|
1420
|
+
// 'multipart/form-data': undefined,
|
1421
|
+
// boundary: 'Asrf456BGe4h'
|
1422
|
+
// }
|
1423
|
+
|
1424
|
+
|
1425
|
+
console.log(headers.get('Content-Type', (value, name, headers) => {
|
1426
|
+
return String(value).replace(/a/g, 'ZZZ');
|
1427
|
+
}));
|
1428
|
+
// multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h
|
1429
|
+
|
1430
|
+
console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]);
|
1431
|
+
// boundary=Asrf456BGe4h
|
1432
|
+
|
1433
|
+
```
|
1434
|
+
|
1435
|
+
Returns the value of the header.
|
1436
|
+
|
1437
|
+
### AxiosHeaders#has(header, matcher?)
|
1438
|
+
|
1439
|
+
```
|
1440
|
+
has(header: string, matcher?: AxiosHeaderMatcher): boolean;
|
1441
|
+
```
|
1442
|
+
|
1443
|
+
Returns `true` if the header is set (has no `undefined` value).
|
1444
|
+
|
1445
|
+
### AxiosHeaders#delete(header, matcher?)
|
1446
|
+
|
1447
|
+
```
|
1448
|
+
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
1449
|
+
```
|
1450
|
+
|
1451
|
+
Returns `true` if at least one header has been removed.
|
1452
|
+
|
1453
|
+
### AxiosHeaders#clear(matcher?)
|
1454
|
+
|
1455
|
+
```
|
1456
|
+
clear(matcher?: AxiosHeaderMatcher): boolean;
|
1457
|
+
```
|
1458
|
+
|
1459
|
+
Removes all headers.
|
1460
|
+
Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value.
|
1461
|
+
|
1462
|
+
```ts
|
1463
|
+
const headers = new AxiosHeaders({
|
1464
|
+
'foo': '1',
|
1465
|
+
'x-foo': '2',
|
1466
|
+
'x-bar': '3',
|
1467
|
+
});
|
1468
|
+
|
1469
|
+
console.log(headers.clear(/^x-/)); // true
|
1470
|
+
|
1471
|
+
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' }
|
1472
|
+
```
|
1473
|
+
|
1474
|
+
Returns `true` if at least one header has been cleared.
|
1475
|
+
|
1476
|
+
### AxiosHeaders#normalize(format);
|
1477
|
+
|
1478
|
+
If the headers object was changed directly, it can have duplicates with the same name but in different cases.
|
1479
|
+
This method normalizes the headers object by combining duplicate keys into one.
|
1480
|
+
Axios uses this method internally after calling each interceptor.
|
1481
|
+
Set `format` to true for converting headers name to lowercase and capitalize the initial letters (`cOntEnt-type` => `Content-Type`)
|
1482
|
+
|
1483
|
+
```js
|
1484
|
+
const headers = new AxiosHeaders({
|
1485
|
+
'foo': '1',
|
1486
|
+
});
|
1487
|
+
|
1488
|
+
headers.Foo = '2';
|
1489
|
+
headers.FOO = '3';
|
1490
|
+
|
1491
|
+
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' }
|
1492
|
+
console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' }
|
1493
|
+
console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' }
|
1494
|
+
```
|
1495
|
+
|
1496
|
+
Returns `this`.
|
1497
|
+
|
1498
|
+
### AxiosHeaders#concat(...targets)
|
1499
|
+
|
1500
|
+
```
|
1501
|
+
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
1502
|
+
```
|
1503
|
+
|
1504
|
+
Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers.
|
1505
|
+
|
1506
|
+
Returns a new `AxiosHeaders` instance.
|
1507
|
+
|
1508
|
+
### AxiosHeaders#toJSON(asStrings?)
|
1509
|
+
|
1510
|
+
````
|
1511
|
+
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
1512
|
+
````
|
1513
|
+
|
1514
|
+
Resolve all internal headers values into a new null prototype object.
|
1515
|
+
Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
|
1516
|
+
|
1517
|
+
### AxiosHeaders.from(thing?)
|
1518
|
+
|
1519
|
+
````
|
1520
|
+
from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
1521
|
+
````
|
1522
|
+
|
1523
|
+
Returns a new `AxiosHeaders` instance created from the raw headers passed in,
|
1524
|
+
or simply returns the given headers object if it's an `AxiosHeaders` instance.
|
1525
|
+
|
1526
|
+
### AxiosHeaders.concat(...targets)
|
1527
|
+
|
1528
|
+
````
|
1529
|
+
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
1530
|
+
````
|
1531
|
+
|
1532
|
+
Returns a new `AxiosHeaders` instance created by merging the target objects.
|
1533
|
+
|
1534
|
+
### Shortcuts
|
1535
|
+
|
1536
|
+
The following shortcuts are available:
|
1537
|
+
|
1538
|
+
- `setContentType`, `getContentType`, `hasContentType`
|
1539
|
+
|
1540
|
+
- `setContentLength`, `getContentLength`, `hasContentLength`
|
1541
|
+
|
1542
|
+
- `setAccept`, `getAccept`, `hasAccept`
|
1543
|
+
|
1544
|
+
- `setUserAgent`, `getUserAgent`, `hasUserAgent`
|
1545
|
+
|
1546
|
+
- `setContentEncoding`, `getContentEncoding`, `hasContentEncoding`
|
1547
|
+
|
1548
|
+
|
1288
1549
|
## Semver
|
1289
1550
|
|
1290
1551
|
Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes.
|