axios 0.19.1 → 0.21.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 +296 -43
- package/README.md +108 -19
- package/UPGRADE_GUIDE.md +1 -1
- package/dist/axios.js +170 -167
- package/dist/axios.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.map +1 -1
- package/index.d.ts +10 -7
- package/lib/adapters/http.js +23 -15
- package/lib/adapters/xhr.js +3 -4
- package/lib/core/Axios.js +4 -3
- package/lib/core/enhanceError.js +1 -1
- package/lib/core/mergeConfig.js +46 -32
- package/lib/core/settle.js +1 -1
- package/lib/defaults.js +1 -0
- package/lib/helpers/buildURL.js +0 -1
- package/lib/helpers/isURLSameOrigin.js +0 -5
- package/lib/utils.js +36 -29
- package/package.json +4 -2
- package/lib/helpers/isValidXss.js +0 -7
package/CHANGELOG.md
CHANGED
@@ -1,61 +1,314 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.21.0 (October 23, 2020)
|
4
|
+
|
5
|
+
Fixes and Functionality:
|
6
|
+
|
7
|
+
- Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287))
|
8
|
+
- Fixing node types ([#3237](https://github.com/axios/axios/pull/3237))
|
9
|
+
- Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282))
|
10
|
+
- Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289))
|
11
|
+
- Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled ([#3200](https://github.com/axios/axios/pull/3200))
|
12
|
+
|
13
|
+
Internal and Tests:
|
14
|
+
|
15
|
+
- Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361))
|
16
|
+
|
17
|
+
Documentation:
|
18
|
+
|
19
|
+
- Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252))
|
20
|
+
- Fixing typos ([#3309](https://github.com/axios/axios/pull/3309))
|
21
|
+
|
22
|
+
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
|
23
|
+
|
24
|
+
- Allan Cruz <57270969+Allanbcruz@users.noreply.github.com>
|
25
|
+
- George Cheng <Gerhut@GMail.com>
|
26
|
+
- Jay <jasonsaayman@gmail.com>
|
27
|
+
- Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
|
28
|
+
- Remco Haszing <remcohaszing@gmail.com>
|
29
|
+
- Taemin Shin <cprayer13@gmail.com>
|
30
|
+
- Tim Gates <tim.gates@iress.com>
|
31
|
+
- Xianming Zhong <chinesedfan@qq.com>
|
32
|
+
|
33
|
+
### 0.20.0 (August 20, 2020)
|
34
|
+
|
35
|
+
Release of 0.20.0-pre as a full release with no other changes.
|
36
|
+
|
37
|
+
### 0.20.0-pre (July 15, 2020)
|
38
|
+
|
39
|
+
Fixes and Functionality:
|
40
|
+
|
41
|
+
- Fixing response with utf-8 BOM can not parse to json ([#2419](https://github.com/axios/axios/pull/2419))
|
42
|
+
- fix: remove byte order marker (UTF-8 BOM) when transform response
|
43
|
+
- fix: remove BOM only utf-8
|
44
|
+
- test: utf-8 BOM
|
45
|
+
- fix: incorrect param name
|
46
|
+
- Refactor mergeConfig without utils.deepMerge ([#2844](https://github.com/axios/axios/pull/2844))
|
47
|
+
- Adding failing test
|
48
|
+
- Fixing #2587 default custom config persisting
|
49
|
+
- Adding Concat keys and filter duplicates
|
50
|
+
- Fixed value from CPE
|
51
|
+
- update for review feedbacks
|
52
|
+
- no deepMerge
|
53
|
+
- only merge between plain objects
|
54
|
+
- fix rename
|
55
|
+
- always merge config by mergeConfig
|
56
|
+
- extract function mergeDeepProperties
|
57
|
+
- refactor mergeConfig with all keys, and add special logic for validateStatus
|
58
|
+
- add test for resetting headers
|
59
|
+
- add lots of tests and fix a bug
|
60
|
+
- should not inherit `data`
|
61
|
+
- use simple toString
|
62
|
+
- Fixing overwrite Blob/File type as Content-Type in browser. ([#1773](https://github.com/axios/axios/pull/1773))
|
63
|
+
- Fixing an issue that type 'null' is not assignable to validateStatus ([#2773](https://github.com/axios/axios/pull/2773))
|
64
|
+
- Fixing special char encoding ([#1671](https://github.com/axios/axios/pull/1671))
|
65
|
+
- removing @ character from replacement list since it is a reserved character
|
66
|
+
- Updating buildURL test to not include the @ character
|
67
|
+
- Removing console logs
|
68
|
+
- Fixing password encoding with special characters in basic authentication ([#1492](https://github.com/axios/axios/pull/1492))
|
69
|
+
- Fixing password encoding with special characters in basic authentication
|
70
|
+
- Adding test to check if password with non-Latin1 characters pass
|
71
|
+
- Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
|
72
|
+
There is a bug in react native Android platform when using get method. It will trigger a 'Network Error' when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug.
|
73
|
+
- Fixing Cookie Helper with Asyc Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
|
74
|
+
- Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
|
75
|
+
- Fix 'progressEvent' type
|
76
|
+
- Update axios.ts
|
77
|
+
- Fixing getting local files (file://) failed ([#2470](https://github.com/axios/axios/pull/2470))
|
78
|
+
- fix issue #2416, #2396
|
79
|
+
- fix Eslint warn
|
80
|
+
- Modify judgment conditions
|
81
|
+
- add unit test
|
82
|
+
- update unit test
|
83
|
+
- update unit test
|
84
|
+
- Allow PURGE method in typings ([#2191](https://github.com/axios/axios/pull/2191))
|
85
|
+
- Adding option to disable automatic decompression ([#2661](https://github.com/axios/axios/pull/2661))
|
86
|
+
- Adding ability to disable auto decompression
|
87
|
+
- Updating decompress documentation in README
|
88
|
+
- Fixing test\unit\adapters\http.js lint errors
|
89
|
+
- Adding test for disabling auto decompression
|
90
|
+
- Removing changes that fixed lint errors in tests
|
91
|
+
- Removing formatting change to unit test
|
92
|
+
- Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781))
|
93
|
+
- Add independent option to set the maximum size of the request body
|
94
|
+
- Remove maxBodyLength check
|
95
|
+
- Update README
|
96
|
+
- Assert for error code and message
|
97
|
+
- Adding responseEncoding to mergeConfig ([#1745](https://github.com/axios/axios/pull/1745))
|
98
|
+
- Compatible with follow-redirect aborts the request ([#2689](https://github.com/axios/axios/pull/2689))
|
99
|
+
- Compatible with follow-redirect aborts the request
|
100
|
+
- Use the error code
|
101
|
+
- Fix merging of params ([#2656](https://github.com/axios/axios/pull/2656))
|
102
|
+
- Name function to avoid ESLint func-names warning
|
103
|
+
- Switch params config to merge list and update tests
|
104
|
+
- Restore testing of both false and null
|
105
|
+
- Restore test cases for keys without defaults
|
106
|
+
- Include test for non-object values that aren't false-y.
|
107
|
+
- Revert `finally` as `then` ([#2683](https://github.com/axios/axios/pull/2683))
|
108
|
+
|
109
|
+
Internal and Tests:
|
110
|
+
|
111
|
+
- Fix stale bot config ([#3049](https://github.com/axios/axios/pull/3049))
|
112
|
+
- fix stale bot config
|
113
|
+
- fix multiple lines
|
114
|
+
- Add days and change name to work ([#3035](https://github.com/axios/axios/pull/3035))
|
115
|
+
- Update close-issues.yml ([#3031](https://github.com/axios/axios/pull/3031))
|
116
|
+
- Update close-issues.yml
|
117
|
+
Update close message to read better 😄
|
118
|
+
- Fix use of quotations
|
119
|
+
Use single quotes as per other .yml files
|
120
|
+
- Remove user name form message
|
121
|
+
- Add GitHub actions to close stale issues/prs ([#3029](https://github.com/axios/axios/pull/3029))
|
122
|
+
- prepare stale actions
|
123
|
+
- update messages
|
124
|
+
- Add exempt labels and lighten up comments
|
125
|
+
- Add GitHub actions to close invalid issues ([#3022](https://github.com/axios/axios/pull/3022))
|
126
|
+
- add close actions
|
127
|
+
- fix with checkout
|
128
|
+
- update issue templates
|
129
|
+
- add reminder
|
130
|
+
- update close message
|
131
|
+
- Add test with Node.js 12 ([#2860](https://github.com/axios/axios/pull/2860))
|
132
|
+
- test with Node.js 12
|
133
|
+
- test with latest
|
134
|
+
- Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210))
|
135
|
+
- Adding console log on sandbox server startup
|
136
|
+
- Update server.js
|
137
|
+
Add server error handling
|
138
|
+
- Update server.js
|
139
|
+
Better error message, remove retry.
|
140
|
+
- Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996))
|
141
|
+
Update tests.
|
142
|
+
- Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695))
|
143
|
+
- Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601))
|
144
|
+
- Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666))
|
145
|
+
- Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748))
|
146
|
+
- chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443))
|
147
|
+
|
148
|
+
Documentation:
|
149
|
+
|
150
|
+
- Adding support for URLSearchParams in node ([#1900](https://github.com/axios/axios/pull/1900))
|
151
|
+
- Adding support for URLSearchParams in node
|
152
|
+
- Remove un-needed code
|
153
|
+
- Update utils.js
|
154
|
+
- Make changes as suggested
|
155
|
+
- Adding table of content (preview) ([#3050](https://github.com/axios/axios/pull/3050))
|
156
|
+
- add toc (preview)
|
157
|
+
- remove toc in toc
|
158
|
+
Signed-off-by: Moni <usmoni@gmail.com>
|
159
|
+
- fix sublinks
|
160
|
+
- fix indentation
|
161
|
+
- remove redundant table links
|
162
|
+
- update caps and indent
|
163
|
+
- remove axios
|
164
|
+
- Replace 'blacklist' with 'blocklist' ([#3006](https://github.com/axios/axios/pull/3006))
|
165
|
+
- docs(): Detailed config options environment. ([#2088](https://github.com/axios/axios/pull/2088))
|
166
|
+
- docs(): Detailed config options environment.
|
167
|
+
- Update README.md
|
168
|
+
- Include axios-data-unpacker in ECOSYSTEM.md ([#2080](https://github.com/axios/axios/pull/2080))
|
169
|
+
- Allow opening examples in Gitpod ([#1958](https://github.com/axios/axios/pull/1958))
|
170
|
+
- Remove axios.all() and axios.spread() from Readme.md ([#2727](https://github.com/axios/axios/pull/2727))
|
171
|
+
- remove axios.all(), axios.spread()
|
172
|
+
- replace example
|
173
|
+
- axios.all() -> Promise.all()
|
174
|
+
- axios.spread(function (acct, perms)) -> function (acct, perms)
|
175
|
+
- add deprecated mark
|
176
|
+
- Update README.md ([#2887](https://github.com/axios/axios/pull/2887))
|
177
|
+
Small change to the data attribute doc of the config. A request body can also be set for DELETE methods but this wasn't mentioned in the documentation (it only mentioned POST, PUT and PATCH). Took my some 10-20 minutes until I realized that I don't need to manipulate the request body with transformRequest in the case of DELETE.
|
178
|
+
- Include swagger-taxos-codegen in ECOSYSTEM.md ([#2162](https://github.com/axios/axios/pull/2162))
|
179
|
+
- Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878))
|
180
|
+
This badge will show the version on CDNJS!
|
181
|
+
- Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928))
|
182
|
+
- Made an adjustment to the documentation to clear up any ambiguity around the use of "fs". This should help clear up that the code examples with "fs" cannot be used on the client side.
|
183
|
+
- Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912))
|
184
|
+
Rewrote the comment from "Reject only if the status code is greater than or equal to 500" to "Resolve only if the status code is less than 500"
|
185
|
+
- Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805))
|
186
|
+
Closes #2049
|
187
|
+
- Fixing CHANGELOG.md issue link ([#2784](https://github.com/axios/axios/pull/2784))
|
188
|
+
- Include axios-hooks in ECOSYSTEM.md ([#2003](https://github.com/axios/axios/pull/2003))
|
189
|
+
- Added Response header access instructions ([#1901](https://github.com/axios/axios/pull/1901))
|
190
|
+
- Added Response header access instructions
|
191
|
+
- Added note about using bracket notation
|
192
|
+
- Add `onUploadProgress` and `onDownloadProgress` are browser only ([#2763](https://github.com/axios/axios/pull/2763))
|
193
|
+
Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README.
|
194
|
+
- Update ' sign to ` in proxy spec ([#2778](https://github.com/axios/axios/pull/2778))
|
195
|
+
- Adding jsDelivr link in README ([#1110](https://github.com/axios/axios/pull/1110))
|
196
|
+
- Adding jsDelivr link
|
197
|
+
- Add SRI
|
198
|
+
- Remove SRI
|
199
|
+
|
200
|
+
Huge thanks to everyone who contributed to this release via code (authors listed
|
201
|
+
below) or via reviews and triaging on GitHub:
|
202
|
+
|
203
|
+
- Alan Wang <wp_scut@163.com>
|
204
|
+
- Alexandru Ungureanu <khakcarot@gmail.com>
|
205
|
+
- Anubhav Srivastava <anubhav.srivastava00@gmail.com>
|
206
|
+
- Benny Neugebauer <bn@bennyn.de>
|
207
|
+
- Cr <631807682@qq.com>
|
208
|
+
- David <cygnidavid@gmail.com>
|
209
|
+
- David Ko <david.ko@pvtmethod.com>
|
210
|
+
- David Tanner <david.tanner@lifeomic.com>
|
211
|
+
- Emily Morehouse <emilyemorehouse@gmail.com>
|
212
|
+
- Felipe Martins <felipewmartins@gmail.com>
|
213
|
+
- Fonger <5862369+Fonger@users.noreply.github.com>
|
214
|
+
- Frostack <soulburn007@gmail.com>
|
215
|
+
- George Cheng <Gerhut@GMail.com>
|
216
|
+
- grumblerchester <grumblerchester@users.noreply.github.com>
|
217
|
+
- Gustavo López <gualopezb@gmail.com>
|
218
|
+
- hexaez <45806662+hexaez@users.noreply.github.com>
|
219
|
+
- huangzuizui <huangzuizui@gmail.com>
|
220
|
+
- Ian Wijma <ian@wij.ma>
|
221
|
+
- Jay <jasonsaayman@gmail.com>
|
222
|
+
- jeffjing <zgayjjf@qq.com>
|
223
|
+
- jennynju <46782518+jennynju@users.noreply.github.com>
|
224
|
+
- Jimmy Liao <52391190+jimmy-liao-gogoro@users.noreply.github.com>
|
225
|
+
- Jonathan Sharpe <j.r.sharpe@gmail.com>
|
226
|
+
- JounQin <admin@1stg.me>
|
227
|
+
- Justin Beckwith <justin.beckwith@gmail.com>
|
228
|
+
- Kamil Posiadała <3dcreator.pl@gmail.com>
|
229
|
+
- Lukas Drgon <lukas.drgon@gmail.com>
|
230
|
+
- marcinx <mail@marcinx.com>
|
231
|
+
- Martti Laine <martti@codeclown.net>
|
232
|
+
- Michał Zarach <michal.m.zarach@gmail.com>
|
233
|
+
- Moni <usmoni@gmail.com>
|
234
|
+
- Motonori Iwata <121048+iwata@users.noreply.github.com>
|
235
|
+
- Nikita Galkin <nikita@galk.in>
|
236
|
+
- Petr Mares <petr@mares.tw>
|
237
|
+
- Philippe Recto <precto1285@gmal.com>
|
238
|
+
- Remco Haszing <remcohaszing@gmail.com>
|
239
|
+
- rockcs1992 <chengshi1219@gmail.com>
|
240
|
+
- Ryan Bown <rbown@niftee.com.au>
|
241
|
+
- Samina Fu <sufuf3@gmail.com>
|
242
|
+
- Simone Busoli <simone.busoli@gmail.com>
|
243
|
+
- Spencer von der Ohe <s.vonderohe40@gmail.com>
|
244
|
+
- Sven Efftinge <sven.efftinge@typefox.io>
|
245
|
+
- Taegyeoung Oh <otk1090@naver.com>
|
246
|
+
- Taemin Shin <cprayer13@gmail.com>
|
247
|
+
- Thibault Ehrhart <1208424+ehrhart@users.noreply.github.com>
|
248
|
+
- Xianming Zhong <chinesedfan@qq.com>
|
249
|
+
- Yasu Flores <carlosyasu91@gmail.com>
|
250
|
+
- Zac Delventhal <delventhalz@gmail.com>
|
251
|
+
|
252
|
+
### 0.19.2 (Jan 20, 2020)
|
253
|
+
|
254
|
+
- Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion)
|
255
|
+
|
3
256
|
### 0.19.1 (Jan 7, 2020)
|
4
257
|
|
5
258
|
Fixes and Functionality:
|
6
259
|
|
7
|
-
- Fixing invalid agent issue (#1904
|
8
|
-
- Fix ignore set withCredentials false (#2582
|
9
|
-
- Delete useless default to hash (#2458
|
10
|
-
- Fix HTTP/HTTPs agents passing to follow-redirect (#1904
|
11
|
-
- Fix ignore set withCredentials false (#2582
|
12
|
-
- Fix CI build failure (#2570
|
13
|
-
- Remove dependency on is-buffer from package.json (#1816
|
14
|
-
- Adding options typings (#2341
|
15
|
-
- Adding Typescript HTTP method definition for LINK and UNLINK. (#2444
|
260
|
+
- Fixing invalid agent issue ([#1904](https://github.com/axios/axios/pull/1904))
|
261
|
+
- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582))
|
262
|
+
- Delete useless default to hash ([#2458](https://github.com/axios/axios/pull/2458))
|
263
|
+
- Fix HTTP/HTTPs agents passing to follow-redirect ([#1904](https://github.com/axios/axios/pull/1904))
|
264
|
+
- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582))
|
265
|
+
- Fix CI build failure ([#2570](https://github.com/axios/axios/pull/2570))
|
266
|
+
- Remove dependency on is-buffer from package.json ([#1816](https://github.com/axios/axios/pull/1816))
|
267
|
+
- Adding options typings ([#2341](https://github.com/axios/axios/pull/2341))
|
268
|
+
- Adding Typescript HTTP method definition for LINK and UNLINK. ([#2444](https://github.com/axios/axios/pull/2444))
|
16
269
|
- Update dist with newest changes, fixes Custom Attributes issue
|
17
|
-
- Change syntax to see if build passes (#2488
|
18
|
-
- Update Webpack + deps, remove now unnecessary polyfills (#2410
|
19
|
-
- Fix to prevent XSS, throw an error when the URL contains a JS script (#2464
|
20
|
-
- Add custom timeout error copy in config (#2275
|
21
|
-
- Add error toJSON example (#2466
|
22
|
-
- Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… (#2451
|
23
|
-
- Fixing subdomain handling on no_proxy (#2442
|
24
|
-
- Make redirection from HTTP to HTTPS work (#2426
|
25
|
-
- Add toJSON property to AxiosError type (#2427
|
26
|
-
- Fixing socket hang up error on node side for slow response. (#1752
|
27
|
-
- Alternative syntax to send data into the body (#2317
|
28
|
-
- Fixing custom config options (#2207
|
29
|
-
- Fixing set `config.method` after mergeConfig for Axios.prototype.request (#2383
|
30
|
-
- Axios create url bug (#2290
|
31
|
-
- Do not modify config.url when using a relative baseURL (resolves [#1628](https://github.com/axios/axios/issues/1098)) (#2391
|
270
|
+
- Change syntax to see if build passes ([#2488](https://github.com/axios/axios/pull/2488))
|
271
|
+
- Update Webpack + deps, remove now unnecessary polyfills ([#2410](https://github.com/axios/axios/pull/2410))
|
272
|
+
- Fix to prevent XSS, throw an error when the URL contains a JS script ([#2464](https://github.com/axios/axios/pull/2464))
|
273
|
+
- Add custom timeout error copy in config ([#2275](https://github.com/axios/axios/pull/2275))
|
274
|
+
- Add error toJSON example ([#2466](https://github.com/axios/axios/pull/2466))
|
275
|
+
- Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… ([#2451](https://github.com/axios/axios/pull/2451))
|
276
|
+
- Fixing subdomain handling on no_proxy ([#2442](https://github.com/axios/axios/pull/2442))
|
277
|
+
- Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426)) and ([#2547](https://github.com/axios/axios/pull/2547))
|
278
|
+
- Add toJSON property to AxiosError type ([#2427](https://github.com/axios/axios/pull/2427))
|
279
|
+
- Fixing socket hang up error on node side for slow response. ([#1752](https://github.com/axios/axios/pull/1752))
|
280
|
+
- Alternative syntax to send data into the body ([#2317](https://github.com/axios/axios/pull/2317))
|
281
|
+
- Fixing custom config options ([#2207](https://github.com/axios/axios/pull/2207))
|
282
|
+
- Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383))
|
283
|
+
- Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290))
|
284
|
+
- Do not modify config.url when using a relative baseURL (resolves [#1628](https://github.com/axios/axios/issues/1098)) ([#2391](https://github.com/axios/axios/pull/2391))
|
32
285
|
- Add typescript HTTP method definition for LINK and UNLINK ([#2444](https://github.com/axios/axios/pull/2444))
|
33
286
|
|
34
287
|
Internal:
|
35
288
|
|
36
|
-
- Revert "Update Webpack + deps, remove now unnecessary polyfills" (#2479
|
37
|
-
- Order of if/else blocks is causing unit tests mocking XHR. (#2201
|
38
|
-
- Add license badge (#2446
|
289
|
+
- Revert "Update Webpack + deps, remove now unnecessary polyfills" ([#2479](https://github.com/axios/axios/pull/2479))
|
290
|
+
- Order of if/else blocks is causing unit tests mocking XHR. ([#2201](https://github.com/axios/axios/pull/2201))
|
291
|
+
- Add license badge ([#2446](https://github.com/axios/axios/pull/2446))
|
39
292
|
- Fix travis CI build [#2386](https://github.com/axios/axios/pull/2386)
|
40
|
-
- Fix cancellation error on build master. #2290 #2207 (#2407
|
293
|
+
- Fix cancellation error on build master. #2290 #2207 ([#2407](https://github.com/axios/axios/pull/2407))
|
41
294
|
|
42
295
|
Documentation:
|
43
296
|
|
44
|
-
- Fixing typo in CHANGELOG.md: s/Functionallity/Functionality (#2639
|
45
|
-
- Fix badge, use master branch (#2538
|
297
|
+
- Fixing typo in CHANGELOG.md: s/Functionallity/Functionality ([#2639](https://github.com/axios/axios/pull/2639))
|
298
|
+
- Fix badge, use master branch ([#2538](https://github.com/axios/axios/pull/2538))
|
46
299
|
- Fix typo in changelog [#2193](https://github.com/axios/axios/pull/2193)
|
47
|
-
- Document fix (#2514
|
48
|
-
- Update docs with no_proxy change, issue #2484 (#2513
|
49
|
-
- Fixing missing words in docs template (#2259
|
50
|
-
- 🐛Fix request finally documentation in README (#2189
|
51
|
-
- updating spelling and adding link to docs (#2212
|
52
|
-
- docs: minor tweak (#2404
|
53
|
-
- Update response interceptor docs (#2399
|
54
|
-
- Update README.md (#2504
|
55
|
-
- Fix word 'sintaxe' to 'syntax' in README.md (#2432
|
56
|
-
-
|
57
|
-
- Fix grammar in README.md (#2271
|
58
|
-
- Doc fixes, minor examples cleanup (#2198
|
300
|
+
- Document fix ([#2514](https://github.com/axios/axios/pull/2514))
|
301
|
+
- Update docs with no_proxy change, issue #2484 ([#2513](https://github.com/axios/axios/pull/2513))
|
302
|
+
- Fixing missing words in docs template ([#2259](https://github.com/axios/axios/pull/2259))
|
303
|
+
- 🐛Fix request finally documentation in README ([#2189](https://github.com/axios/axios/pull/2189))
|
304
|
+
- updating spelling and adding link to docs ([#2212](https://github.com/axios/axios/pull/2212))
|
305
|
+
- docs: minor tweak ([#2404](https://github.com/axios/axios/pull/2404))
|
306
|
+
- Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399))
|
307
|
+
- Update README.md ([#2504](https://github.com/axios/axios/pull/2504))
|
308
|
+
- Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432))
|
309
|
+
- updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
|
310
|
+
- Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271))
|
311
|
+
- Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198))
|
59
312
|
|
60
313
|
### 0.19.0 (May 30, 2019)
|
61
314
|
|
@@ -106,7 +359,7 @@ New Functionality:
|
|
106
359
|
|
107
360
|
- Add getUri method ([#1712](https://github.com/axios/axios/issues/1712))
|
108
361
|
- Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693))
|
109
|
-
- Add toJSON to decorated Axios errors to
|
362
|
+
- Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625))
|
110
363
|
- Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623))
|
111
364
|
- Typings: allow custom return types
|
112
365
|
- Add option to specify character set in responses (with http adapter)
|
package/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# axios
|
2
2
|
|
3
3
|
[](https://www.npmjs.org/package/axios)
|
4
|
+
[](https://cdnjs.com/libraries/axios)
|
4
5
|
[](https://travis-ci.org/axios/axios)
|
5
6
|
[](https://coveralls.io/r/mzabriskie/axios)
|
6
7
|
[](https://packagephobia.now.sh/result?p=axios)
|
@@ -9,6 +10,37 @@
|
|
9
10
|
[](https://www.codetriage.com/axios/axios)
|
10
11
|
|
11
12
|
Promise based HTTP client for the browser and node.js
|
13
|
+
## Table of Contents
|
14
|
+
|
15
|
+
- [Features](#features)
|
16
|
+
- [Browser Support](#browser-support)
|
17
|
+
- [Installing](#installing)
|
18
|
+
- [Example](#example)
|
19
|
+
- [Axios API](#axios-api)
|
20
|
+
- [Request method aliases](#request-method-aliases)
|
21
|
+
- [Concurrency (Deprecated)](#concurrency-deprecated)
|
22
|
+
- [Creating an instance](#creating-an-instance)
|
23
|
+
- [Instance methods](#instance-methods)
|
24
|
+
- [Request Config](#request-config)
|
25
|
+
- [Response Schema](#response-schema)
|
26
|
+
- [Config Defaults](#config-defaults)
|
27
|
+
- [Global axios defaults](#global-axios-defaults)
|
28
|
+
- [Custom instance defaults](#custom-instance-defaults)
|
29
|
+
- [Config order of precedence](#config-order-of-precedence)
|
30
|
+
- [Interceptors](#interceptors)
|
31
|
+
- [Handling Errors](#handling-errors)
|
32
|
+
- [Cancellation](#cancellation)
|
33
|
+
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
|
34
|
+
- [Browser](#browser)
|
35
|
+
- [Node.js](#nodejs)
|
36
|
+
- [Query string](#query-string)
|
37
|
+
- [Form data](#form-data)
|
38
|
+
- [Semver](#semver)
|
39
|
+
- [Promises](#promises)
|
40
|
+
- [TypeScript](#typescript)
|
41
|
+
- [Resources](#resources)
|
42
|
+
- [Credits](#credits)
|
43
|
+
- [License](#license)
|
12
44
|
|
13
45
|
## Features
|
14
46
|
|
@@ -49,7 +81,13 @@ Using yarn:
|
|
49
81
|
$ yarn add axios
|
50
82
|
```
|
51
83
|
|
52
|
-
Using
|
84
|
+
Using jsDelivr CDN:
|
85
|
+
|
86
|
+
```html
|
87
|
+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
88
|
+
```
|
89
|
+
|
90
|
+
Using unpkg CDN:
|
53
91
|
|
54
92
|
```html
|
55
93
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
@@ -81,7 +119,7 @@ axios.get('/user?ID=12345')
|
|
81
119
|
// handle error
|
82
120
|
console.log(error);
|
83
121
|
})
|
84
|
-
.
|
122
|
+
.then(function () {
|
85
123
|
// always executed
|
86
124
|
});
|
87
125
|
|
@@ -97,7 +135,7 @@ axios.get('/user', {
|
|
97
135
|
.catch(function (error) {
|
98
136
|
console.log(error);
|
99
137
|
})
|
100
|
-
.
|
138
|
+
.then(function () {
|
101
139
|
// always executed
|
102
140
|
});
|
103
141
|
|
@@ -141,10 +179,11 @@ function getUserPermissions() {
|
|
141
179
|
return axios.get('/user/12345/permissions');
|
142
180
|
}
|
143
181
|
|
144
|
-
|
145
|
-
.then(
|
146
|
-
|
147
|
-
|
182
|
+
Promise.all([getUserAccount(), getUserPermissions()])
|
183
|
+
.then(function (results) {
|
184
|
+
const acct = results[0];
|
185
|
+
const perm = results[1];
|
186
|
+
});
|
148
187
|
```
|
149
188
|
|
150
189
|
## axios API
|
@@ -166,7 +205,7 @@ axios({
|
|
166
205
|
```
|
167
206
|
|
168
207
|
```js
|
169
|
-
// GET request for remote image
|
208
|
+
// GET request for remote image in node.js
|
170
209
|
axios({
|
171
210
|
method: 'get',
|
172
211
|
url: 'http://bit.ly/2mTM3nY',
|
@@ -200,12 +239,13 @@ For convenience aliases have been provided for all supported request methods.
|
|
200
239
|
###### NOTE
|
201
240
|
When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
|
202
241
|
|
203
|
-
### Concurrency
|
242
|
+
### Concurrency (Deprecated)
|
243
|
+
Please use `Promise.all` to replace the below functions.
|
204
244
|
|
205
245
|
Helper functions for dealing with concurrent requests.
|
206
246
|
|
207
|
-
|
208
|
-
|
247
|
+
axios.all(iterable)
|
248
|
+
axios.spread(callback)
|
209
249
|
|
210
250
|
### Creating an instance
|
211
251
|
|
@@ -287,7 +327,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
287
327
|
},
|
288
328
|
|
289
329
|
// `data` is the data to be sent as the request body
|
290
|
-
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
|
330
|
+
// Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
|
291
331
|
// When no `transformRequest` is set, must be of one of the following types:
|
292
332
|
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
|
293
333
|
// - Browser only: FormData, File, Blob
|
@@ -330,7 +370,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
330
370
|
// browser only: 'blob'
|
331
371
|
responseType: 'json', // default
|
332
372
|
|
333
|
-
// `responseEncoding` indicates encoding to use for decoding responses
|
373
|
+
// `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
|
334
374
|
// Note: Ignored for `responseType` of 'stream' or client-side requests
|
335
375
|
responseEncoding: 'utf8', // default
|
336
376
|
|
@@ -341,18 +381,23 @@ These are the available config options for making requests. Only the `url` is re
|
|
341
381
|
xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
342
382
|
|
343
383
|
// `onUploadProgress` allows handling of progress events for uploads
|
384
|
+
// browser only
|
344
385
|
onUploadProgress: function (progressEvent) {
|
345
386
|
// Do whatever you want with the native progress event
|
346
387
|
},
|
347
388
|
|
348
389
|
// `onDownloadProgress` allows handling of progress events for downloads
|
390
|
+
// browser only
|
349
391
|
onDownloadProgress: function (progressEvent) {
|
350
392
|
// Do whatever you want with the native progress event
|
351
393
|
},
|
352
394
|
|
353
|
-
// `maxContentLength` defines the max size of the http response content in bytes allowed
|
395
|
+
// `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
|
354
396
|
maxContentLength: 2000,
|
355
397
|
|
398
|
+
// `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
|
399
|
+
maxBodyLength: 2000,
|
400
|
+
|
356
401
|
// `validateStatus` defines whether to resolve or reject the promise for a given
|
357
402
|
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
|
358
403
|
// or `undefined`), the promise will be resolved; otherwise, the promise will be
|
@@ -377,7 +422,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
377
422
|
httpAgent: new http.Agent({ keepAlive: true }),
|
378
423
|
httpsAgent: new https.Agent({ keepAlive: true }),
|
379
424
|
|
380
|
-
//
|
425
|
+
// `proxy` defines the hostname and port of the proxy server.
|
381
426
|
// You can also define your proxy using the conventional `http_proxy` and
|
382
427
|
// `https_proxy` environment variables. If you are using environment variables
|
383
428
|
// for your proxy configuration, you can also define a `no_proxy` environment
|
@@ -399,7 +444,14 @@ These are the available config options for making requests. Only the `url` is re
|
|
399
444
|
// `cancelToken` specifies a cancel token that can be used to cancel the request
|
400
445
|
// (see Cancellation section below for details)
|
401
446
|
cancelToken: new CancelToken(function (cancel) {
|
402
|
-
})
|
447
|
+
}),
|
448
|
+
|
449
|
+
// `decompress` indicates whether or not the response body should be decompressed
|
450
|
+
// automatically. If set to `true` will also remove the 'content-encoding' header
|
451
|
+
// from the responses objects of all decompressed responses
|
452
|
+
// - Node only (XHR cannot turn off decompression)
|
453
|
+
decompress: true // default
|
454
|
+
|
403
455
|
}
|
404
456
|
```
|
405
457
|
|
@@ -418,8 +470,9 @@ The response for a request contains the following information.
|
|
418
470
|
// `statusText` is the HTTP status message from the server response
|
419
471
|
statusText: 'OK',
|
420
472
|
|
421
|
-
// `headers` the headers that the server responded with
|
422
|
-
// All header names are lower cased
|
473
|
+
// `headers` the HTTP headers that the server responded with
|
474
|
+
// All header names are lower cased and can be accessed using the bracket notation.
|
475
|
+
// Example: `response.headers['content-type']`
|
423
476
|
headers: {},
|
424
477
|
|
425
478
|
// `config` is the config that was provided to `axios` for the request
|
@@ -559,7 +612,7 @@ Using the `validateStatus` config option, you can define HTTP code(s) that shoul
|
|
559
612
|
```js
|
560
613
|
axios.get('/user/12345', {
|
561
614
|
validateStatus: function (status) {
|
562
|
-
return status < 500; //
|
615
|
+
return status < 500; // Resolve only if the status code is less than 500
|
563
616
|
}
|
564
617
|
})
|
565
618
|
```
|
@@ -664,6 +717,8 @@ axios(options);
|
|
664
717
|
|
665
718
|
### Node.js
|
666
719
|
|
720
|
+
#### Query string
|
721
|
+
|
667
722
|
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
|
668
723
|
|
669
724
|
```js
|
@@ -671,11 +726,45 @@ const querystring = require('querystring');
|
|
671
726
|
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
|
672
727
|
```
|
673
728
|
|
729
|
+
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows:
|
730
|
+
|
731
|
+
```js
|
732
|
+
const url = require('url');
|
733
|
+
const params = new url.URLSearchParams({ foo: 'bar' });
|
734
|
+
axios.post('http://something.com/', params.toString());
|
735
|
+
```
|
736
|
+
|
674
737
|
You can also use the [`qs`](https://github.com/ljharb/qs) library.
|
675
738
|
|
676
739
|
###### NOTE
|
677
740
|
The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665).
|
678
741
|
|
742
|
+
#### Form data
|
743
|
+
|
744
|
+
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows:
|
745
|
+
|
746
|
+
```js
|
747
|
+
const FormData = require('form-data');
|
748
|
+
|
749
|
+
const form = new FormData();
|
750
|
+
form.append('my_field', 'my value');
|
751
|
+
form.append('my_buffer', new Buffer(10));
|
752
|
+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
753
|
+
|
754
|
+
axios.post('https://example.com', form, { headers: form.getHeaders() })
|
755
|
+
```
|
756
|
+
|
757
|
+
Alternatively, use an interceptor:
|
758
|
+
|
759
|
+
```js
|
760
|
+
axios.interceptors.request.use(config => {
|
761
|
+
if (config.data instanceof FormData) {
|
762
|
+
Object.assign(config.headers, config.data.getHeaders());
|
763
|
+
}
|
764
|
+
return config;
|
765
|
+
});
|
766
|
+
```
|
767
|
+
|
679
768
|
## Semver
|
680
769
|
|
681
770
|
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.
|
package/UPGRADE_GUIDE.md
CHANGED
@@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once.
|
|
135
135
|
|
136
136
|
#### `axios.success`/`axios.error`
|
137
137
|
|
138
|
-
The `success`, and `error` aliases were
|
138
|
+
The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
|
139
139
|
|
140
140
|
```js
|
141
141
|
axios.get('some/url')
|