axios 1.1.3 → 1.2.0-alpha.1
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 +123 -74
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +55 -20
- package/dist/axios.js +356 -211
- 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 +3010 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +296 -216
- 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 +224 -166
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +490 -0
- package/index.d.ts +28 -10
- package/index.js +8 -3
- package/karma.conf.cjs +1 -1
- package/lib/adapters/http.js +2 -2
- package/lib/adapters/xhr.js +2 -1
- package/lib/axios.js +7 -3
- package/lib/core/Axios.js +10 -8
- package/lib/core/AxiosHeaders.js +82 -76
- package/lib/core/dispatchRequest.js +4 -0
- package/lib/core/mergeConfig.js +50 -46
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/utils.js +36 -8
- package/package.json +13 -6
- package/rollup.config.js +37 -10
- package/tsconfig.json +2 -7
- package/tslint.json +6 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,128 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.2.0] - 2022-11-10
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
- changed: refactored module exports [#5162](https://github.com/axios/axios/pull/5162)
|
8
|
+
- change: re-added support for loading Axios with require('axios').default [#5225](https://github.com/axios/axios/pull/5225)
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- fix: improve AxiosHeaders class [#5224](https://github.com/axios/axios/pull/5224)
|
13
|
+
- fix: TypeScript type definitions for commonjs [#5196](https://github.com/axios/axios/pull/5196)
|
14
|
+
- fix: type definition of use method on AxiosInterceptorManager to match the the README [#5071](https://github.com/axios/axios/pull/5071)
|
15
|
+
|
16
|
+
### Chores
|
17
|
+
|
18
|
+
- chore: force CI restart [#5243](https://github.com/axios/axios/pull/5243)
|
19
|
+
- chore: update ECOSYSTEM.md [#5077](https://github.com/axios/axios/pull/5077)
|
20
|
+
- chore: update get/index.html [#5116](https://github.com/axios/axios/pull/5116)
|
21
|
+
- chore: update Sandbox UI/UX [#5205](https://github.com/axios/axios/pull/5205)
|
22
|
+
- chore(packages) bump socket.io-parser from 4.0.4 to 4.0.5 [#5241](https://github.com/axios/axios/pull/5241)
|
23
|
+
- chore(packages): bump loader-utils from 1.4.0 to 1.4.1 [#5245](https://github.com/axios/axios/pull/5245)
|
24
|
+
- chore(docs): update Resources links in README [#5119](https://github.com/axios/axios/pull/5119)
|
25
|
+
- chore(docs): fix broken links [#5218](https://github.com/axios/axios/pull/5218)
|
26
|
+
- chore(docs): update and rename UPGRADE_GUIDE.md to MIGRATION_GUIDE.md [#5170](https://github.com/axios/axios/pull/5170)
|
27
|
+
- chore(docs): typo fix line #856 and #920 [#5194](https://github.com/axios/axios/pull/5194)
|
28
|
+
- chore(docs): typo fix #800 [#5193](https://github.com/axios/axios/pull/5193)
|
29
|
+
- chore(docs): fix typos [#5184](https://github.com/axios/axios/pull/5184)
|
30
|
+
- chore(docs): fix punctuation in README.md [#5197](https://github.com/axios/axios/pull/5197)
|
31
|
+
- chore: remove \b from filename [#5207](https://github.com/axios/axios/pull/5207)
|
32
|
+
- chore(docs): update CHANGELOG.md [#5137](https://github.com/axios/axios/pull/5137)
|
33
|
+
- chore: add sideEffects false to package.json [#5025](https://github.com/axios/axios/pull/5025)
|
34
|
+
|
35
|
+
### Contributors to this release
|
36
|
+
|
37
|
+
- [Maddy Miller](https://github.com/me4502)
|
38
|
+
- [Amit Saini](https://github.com/amitsainii)
|
39
|
+
- [ecyrbe](https://github.com/ecyrbe)
|
40
|
+
- [Ikko Ashimine](https://github.com/eltociear)
|
41
|
+
- [Geeth Gunnampalli](https://github.com/thetechie7)
|
42
|
+
- [Shreem Asati](https://github.com/shreem-123)
|
43
|
+
- [Frieder Bluemle](https://github.com/friederbluemle)
|
44
|
+
- [윤세영](https://github.com/yunseyeong)
|
45
|
+
- [Claudio Busatto](https://github.com/cjcbusatto)
|
46
|
+
- [Remco Haszing](https://github.com/remcohaszing)
|
47
|
+
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
48
|
+
- [Csaba Maulis](https://github.com/om4csaba)
|
49
|
+
- [MoPaMo](https://github.com/MoPaMo)
|
50
|
+
- [Daniel Fjeldstad](https://github.com/w3bdesign)
|
51
|
+
- [Adrien Brunet](https://github.com/adrien-may)
|
52
|
+
|
53
|
+
## [1.1.3] - 2022-10-15
|
54
|
+
|
55
|
+
### Added
|
56
|
+
|
57
|
+
- Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113)
|
58
|
+
|
59
|
+
### Fixed
|
60
|
+
|
61
|
+
- Fixed top-level export to keep them in-line with static properties [#5109](https://github.com/axios/axios/pull/5109)
|
62
|
+
- Stopped including null values to query string. [#5108](https://github.com/axios/axios/pull/5108)
|
63
|
+
- Restored proxy config backwards compatibility with 0.x [#5097](https://github.com/axios/axios/pull/5097)
|
64
|
+
- Added back AxiosHeaders in AxiosHeaderValue [#5103](https://github.com/axios/axios/pull/5103)
|
65
|
+
- Pin CDN install instructions to a specific version [#5060](https://github.com/axios/axios/pull/5060)
|
66
|
+
- Handling of array values fixed for AxiosHeaders [#5085](https://github.com/axios/axios/pull/5085)
|
67
|
+
|
68
|
+
### Chores
|
69
|
+
|
70
|
+
- docs: match badge style, add link to them [#5046](https://github.com/axios/axios/pull/5046)
|
71
|
+
- chore: fixing comments typo [#5054](https://github.com/axios/axios/pull/5054)
|
72
|
+
- chore: update issue template [#5061](https://github.com/axios/axios/pull/5061)
|
73
|
+
- chore: added progress capturing section to the docs; [#5084](https://github.com/axios/axios/pull/5084)
|
74
|
+
|
75
|
+
### Contributors to this release
|
76
|
+
|
77
|
+
- [Jason Saayman](https://github.com/jasonsaayman)
|
78
|
+
- [scarf](https://github.com/scarf005)
|
79
|
+
- [Lenz Weber-Tronic](https://github.com/phryneas)
|
80
|
+
- [Arvindh](https://github.com/itsarvindh)
|
81
|
+
- [Félix Legrelle](https://github.com/FelixLgr)
|
82
|
+
- [Patrick Petrovic](https://github.com/ppati000)
|
83
|
+
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
84
|
+
- [littledian](https://github.com/littledian)
|
85
|
+
- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime)
|
86
|
+
|
87
|
+
## [1.1.2] - 2022-10-07
|
88
|
+
|
89
|
+
### Fixed
|
90
|
+
|
91
|
+
- Fixed broken exports for UMD builds.
|
92
|
+
|
93
|
+
### Contributors to this release
|
94
|
+
|
95
|
+
- [Jason Saayman](https://github.com/jasonsaayman)
|
96
|
+
|
97
|
+
## [1.1.1] - 2022-10-07
|
98
|
+
|
99
|
+
### Fixed
|
100
|
+
|
101
|
+
- Fixed broken exports for common js. This fix breaks a prior fix, I will fix both issues ASAP but the commonJS use is more impactful.
|
102
|
+
|
103
|
+
### Contributors to this release
|
104
|
+
|
105
|
+
- [Jason Saayman](https://github.com/jasonsaayman)
|
106
|
+
|
107
|
+
## [1.1.0] - 2022-10-06
|
108
|
+
|
109
|
+
### Fixed
|
110
|
+
|
111
|
+
- Fixed missing exports in type definition index.d.ts [#5003](https://github.com/axios/axios/pull/5003)
|
112
|
+
- Fixed query params composing [#5018](https://github.com/axios/axios/pull/5018)
|
113
|
+
- Fixed GenericAbortSignal interface by making it more generic [#5021](https://github.com/axios/axios/pull/5021)
|
114
|
+
- Fixed adding "clear" to AxiosInterceptorManager [#5010](https://github.com/axios/axios/pull/5010)
|
115
|
+
- Fixed commonjs & umd exports [#5030](https://github.com/axios/axios/pull/5030)
|
116
|
+
- Fixed inability to access response headers when using axios 1.x with Jest [#5036](https://github.com/axios/axios/pull/5036)
|
117
|
+
|
118
|
+
### Contributors to this release
|
119
|
+
|
120
|
+
- [Trim21](https://github.com/trim21)
|
121
|
+
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
122
|
+
- [shingo.sasaki](https://github.com/s-sasaki-0529)
|
123
|
+
- [Ivan Pepelko](https://github.com/ivanpepelko)
|
124
|
+
- [Richard Kořínek](https://github.com/risa)
|
125
|
+
|
3
126
|
## [1.0.0] - 2022-10-04
|
4
127
|
|
5
128
|
### Added
|
@@ -179,77 +302,3 @@
|
|
179
302
|
- [Luca Pizzini](https://github.com/lpizzinidev)
|
180
303
|
- [Willian Agostini](https://github.com/WillianAgostini)
|
181
304
|
- [Huyen Nguyen](https://github.com/huyenltnguyen)
|
182
|
-
|
183
|
-
## [1.1.0] - 2022-10-06
|
184
|
-
|
185
|
-
### Fixed
|
186
|
-
|
187
|
-
- Fixed missing exports in type definition index.d.ts [#5003](https://github.com/axios/axios/pull/5003)
|
188
|
-
- Fixed query params composing [#5018](https://github.com/axios/axios/pull/5018)
|
189
|
-
- Fixed GenericAbortSignal interface by making it more generic [#5021](https://github.com/axios/axios/pull/5021)
|
190
|
-
- Fixed adding "clear" to AxiosInterceptorManager [#5010](https://github.com/axios/axios/pull/5010)
|
191
|
-
- Fixed commonjs & umd exports [#5030](https://github.com/axios/axios/pull/5030)
|
192
|
-
- Fixed inability to access response headers when using axios 1.x with Jest [#5036](https://github.com/axios/axios/pull/5036)
|
193
|
-
|
194
|
-
### Contributors to this release
|
195
|
-
|
196
|
-
- [Trim21](https://github.com/trim21)
|
197
|
-
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
198
|
-
- [shingo.sasaki](https://github.com/s-sasaki-0529)
|
199
|
-
- [Ivan Pepelko](https://github.com/ivanpepelko)
|
200
|
-
- [Richard Kořínek](https://github.com/risa)
|
201
|
-
|
202
|
-
## [1.1.1] - 2022-10-07
|
203
|
-
|
204
|
-
### Fixed
|
205
|
-
|
206
|
-
- Fixed broken exports for common js. This fix breaks a prior fix, I will fix both issues ASAP but the commonJS use is more impactful.
|
207
|
-
|
208
|
-
### Contributors to this release
|
209
|
-
|
210
|
-
- [Jason Saayman](https://github.com/jasonsaayman)
|
211
|
-
|
212
|
-
## [1.1.2] - 2022-10-07
|
213
|
-
|
214
|
-
### Fixed
|
215
|
-
|
216
|
-
- Fixed broken exports for UMD builds.
|
217
|
-
|
218
|
-
### Contributors to this release
|
219
|
-
|
220
|
-
- [Jason Saayman](https://github.com/jasonsaayman)
|
221
|
-
|
222
|
-
## [1.1.3] - 2022-10-15
|
223
|
-
|
224
|
-
### Added
|
225
|
-
Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113)
|
226
|
-
|
227
|
-
### Fixed
|
228
|
-
|
229
|
-
Fixed top-level export to keep them in-line with static properties [#5109](https://github.com/axios/axios/pull/5109)
|
230
|
-
Stopped including null values to query string. [#5108](https://github.com/axios/axios/pull/5108)
|
231
|
-
Restored proxy config backwards compatibility with 0.x [#5097](https://github.com/axios/axios/pull/5097)
|
232
|
-
Added back AxiosHeaders in AxiosHeaderValue [#5103](https://github.com/axios/axios/pull/5103)
|
233
|
-
Pin CDN install instructions to a specific version [#5060](https://github.com/axios/axios/pull/5060)
|
234
|
-
Handling of array values fixed for AxiosHeaders [#5085](https://github.com/axios/axios/pull/5085)
|
235
|
-
|
236
|
-
### Chores
|
237
|
-
|
238
|
-
docs: match badge style, add link to them [#5046](https://github.com/axios/axios/pull/5046)
|
239
|
-
chore: fixing comments typo [#5054](https://github.com/axios/axios/pull/5054)
|
240
|
-
chore: update issue template [#5061](https://github.com/axios/axios/pull/5061)
|
241
|
-
chore: added progress capturing section to the docs; [#5084](https://github.com/axios/axios/pull/5084)
|
242
|
-
|
243
|
-
### Contributors to this release
|
244
|
-
|
245
|
-
- [Jason Saayman](https://github.com/jasonsaayman)
|
246
|
-
- [scarf](https://github.com/scarf005)
|
247
|
-
- [Lenz Weber-Tronic](https://github.com/phryneas)
|
248
|
-
- [Arvindh](https://github.com/itsarvindh)
|
249
|
-
- [Félix Legrelle](https://github.com/FelixLgr)
|
250
|
-
- [Patrick Petrovic](https://github.com/ppati000)
|
251
|
-
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
252
|
-
- [littledian](https://github.com/littledian)
|
253
|
-
- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime)
|
254
|
-
- [Salman Shaikh](https://github.com/salmannotkhan)
|
255
|
-
|
package/README.md
CHANGED
@@ -35,6 +35,8 @@
|
|
35
35
|
- [Features](#features)
|
36
36
|
- [Browser Support](#browser-support)
|
37
37
|
- [Installing](#installing)
|
38
|
+
- [Package manager](#package-manager)
|
39
|
+
- [CDN](#cdn)
|
38
40
|
- [Example](#example)
|
39
41
|
- [Axios API](#axios-api)
|
40
42
|
- [Request method aliases](#request-method-aliases)
|
@@ -93,6 +95,8 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
|
|
93
95
|
|
94
96
|
## Installing
|
95
97
|
|
98
|
+
### Package manager
|
99
|
+
|
96
100
|
Using npm:
|
97
101
|
|
98
102
|
```bash
|
@@ -117,7 +121,39 @@ Using pnpm:
|
|
117
121
|
$ pnpm add axios
|
118
122
|
```
|
119
123
|
|
120
|
-
|
124
|
+
Once the package is installed, you can import the library using `import` or `require` approach:
|
125
|
+
|
126
|
+
```js
|
127
|
+
import axios, {isCancel, AxiosError} from 'axios';
|
128
|
+
```
|
129
|
+
|
130
|
+
You can also use the default export, since the named export is just a re-export from the Axios factory:
|
131
|
+
|
132
|
+
```js
|
133
|
+
import axios from 'axios';
|
134
|
+
|
135
|
+
console.log(axios.isCancel('something'));
|
136
|
+
````
|
137
|
+
|
138
|
+
If you use `require` for importing, **only default export is available**:
|
139
|
+
|
140
|
+
```js
|
141
|
+
const axios = require('axios');
|
142
|
+
|
143
|
+
console.log(axios.isCancel('something'));
|
144
|
+
```
|
145
|
+
|
146
|
+
For cases where something went wrong when trying to import a module into a custom or legacy environment,
|
147
|
+
you can try importing the module package directly:
|
148
|
+
|
149
|
+
```js
|
150
|
+
const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017)
|
151
|
+
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017)
|
152
|
+
```
|
153
|
+
|
154
|
+
### CDN
|
155
|
+
|
156
|
+
Using jsDelivr CDN (ES5 UMD browser module):
|
121
157
|
|
122
158
|
```html
|
123
159
|
<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script>
|
@@ -131,19 +167,12 @@ Using unpkg CDN:
|
|
131
167
|
|
132
168
|
## Example
|
133
169
|
|
134
|
-
|
135
|
-
In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()
|
170
|
+
> **Note** CommonJS usage
|
171
|
+
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach:
|
136
172
|
|
137
173
|
```js
|
138
|
-
|
139
|
-
|
140
|
-
// axios.<method> will now provide autocomplete and parameter typings
|
141
|
-
```
|
142
|
-
|
143
|
-
Performing a `GET` request
|
144
|
-
|
145
|
-
```js
|
146
|
-
const axios = require('axios').default;
|
174
|
+
import axios from 'axios';
|
175
|
+
//const axios = require('axios'); // legacy way
|
147
176
|
|
148
177
|
// Make a request for a user with a given ID
|
149
178
|
axios.get('/user?ID=12345')
|
@@ -797,7 +826,7 @@ controller.abort()
|
|
797
826
|
|
798
827
|
You can also cancel a request using a *CancelToken*.
|
799
828
|
|
800
|
-
> The axios cancel token API is based on the withdrawn [
|
829
|
+
> The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
|
801
830
|
|
802
831
|
> This API is deprecated since v0.22.0 and shouldn't be used in new projects
|
803
832
|
|
@@ -853,7 +882,7 @@ cancel();
|
|
853
882
|
|
854
883
|
### URLSearchParams
|
855
884
|
|
856
|
-
By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers, [
|
885
|
+
By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers,and [ Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018).
|
857
886
|
|
858
887
|
```js
|
859
888
|
const params = new URLSearchParams({ foo: 'bar' });
|
@@ -917,7 +946,7 @@ await axios.postForm('https://postman-echo.com/post', data,
|
|
917
946
|
);
|
918
947
|
```
|
919
948
|
|
920
|
-
The server will handle it as
|
949
|
+
The server will handle it as:
|
921
950
|
|
922
951
|
```js
|
923
952
|
{
|
@@ -1250,6 +1279,12 @@ try {
|
|
1250
1279
|
}
|
1251
1280
|
```
|
1252
1281
|
|
1282
|
+
Because axios dual publishes with an ESM default export and a CJS `module.exports`, there are some caveats.
|
1283
|
+
The recommended setting is to use `"moduleResolution": "node16"` (this is implied by `"module": "node16"`). Note that this requires TypeScript 4.7 or greater.
|
1284
|
+
If use ESM, your settings should be fine.
|
1285
|
+
If you compile TypeScript to CJS and you can’t use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`.
|
1286
|
+
If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`.
|
1287
|
+
|
1253
1288
|
## Online one-click setup
|
1254
1289
|
|
1255
1290
|
You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online.
|
@@ -1259,11 +1294,11 @@ You can use Gitpod, an online IDE(which is free for Open Source) for contributin
|
|
1259
1294
|
|
1260
1295
|
## Resources
|
1261
1296
|
|
1262
|
-
* [Changelog](https://github.com/axios/axios/blob/
|
1263
|
-
* [Upgrade Guide](https://github.com/axios/axios/blob/
|
1264
|
-
* [Ecosystem](https://github.com/axios/axios/blob/
|
1265
|
-
* [Contributing Guide](https://github.com/axios/axios/blob/
|
1266
|
-
* [Code of Conduct](https://github.com/axios/axios/blob/
|
1297
|
+
* [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
|
1298
|
+
* [Upgrade Guide](https://github.com/axios/axios/blob/v1.x/UPGRADE_GUIDE.md)
|
1299
|
+
* [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md)
|
1300
|
+
* [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md)
|
1301
|
+
* [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md)
|
1267
1302
|
|
1268
1303
|
## Credits
|
1269
1304
|
|