axios 0.19.0 → 0.20.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 CHANGED
@@ -1,25 +1,310 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.20.0 (August 20, 2020)
4
+
5
+ Release of 0.20.0-pre as a full release with no other changes.
6
+
7
+ ### 0.20.0-pre (July 15, 2020)
8
+
9
+ Fixes and Functionality:
10
+
11
+ - Fixing response with utf-8 BOM can not parse to json ([#2419](https://github.com/axios/axios/pull/2419))
12
+ - fix: remove byte order marker (UTF-8 BOM) when transform response
13
+ - fix: remove BOM only utf-8
14
+ - test: utf-8 BOM
15
+ - fix: incorrect param name
16
+ - Refactor mergeConfig without utils.deepMerge ([#2844](https://github.com/axios/axios/pull/2844))
17
+ - Adding failing test
18
+ - Fixing #2587 default custom config persisting
19
+ - Adding Concat keys and filter duplicates
20
+ - Fixed value from CPE
21
+ - update for review feedbacks
22
+ - no deepMerge
23
+ - only merge between plain objects
24
+ - fix rename
25
+ - always merge config by mergeConfig
26
+ - extract function mergeDeepProperties
27
+ - refactor mergeConfig with all keys, and add special logic for validateStatus
28
+ - add test for resetting headers
29
+ - add lots of tests and fix a bug
30
+ - should not inherit `data`
31
+ - use simple toString
32
+ - Fixing overwrite Blob/File type as Content-Type in browser. ([#1773](https://github.com/axios/axios/pull/1773))
33
+ - Fixing an issue that type 'null' is not assignable to validateStatus ([#2773](https://github.com/axios/axios/pull/2773))
34
+ - Fixing special char encoding ([#1671](https://github.com/axios/axios/pull/1671))
35
+ - removing @ character from replacement list since it is a reserved character
36
+ - Updating buildURL test to not include the @ character
37
+ - Removing console logs
38
+ - Fixing password encoding with special characters in basic authentication ([#1492](https://github.com/axios/axios/pull/1492))
39
+ - Fixing password encoding with special characters in basic authentication
40
+ - Adding test to check if password with non-Latin1 characters pass
41
+ - Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
42
+ 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.
43
+ - Fixing Cookie Helper with Asyc Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
44
+ - Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
45
+ - Fix 'progressEvent' type
46
+ - Update axios.ts
47
+ - Fixing getting local files (file://) failed ([#2470](https://github.com/axios/axios/pull/2470))
48
+ - fix issue #2416, #2396
49
+ - fix Eslint warn
50
+ - Modify judgment conditions
51
+ - add unit test
52
+ - update unit test
53
+ - update unit test
54
+ - Allow PURGE method in typings ([#2191](https://github.com/axios/axios/pull/2191))
55
+ - Adding option to disable automatic decompression ([#2661](https://github.com/axios/axios/pull/2661))
56
+ - Adding ability to disable auto decompression
57
+ - Updating decompress documentation in README
58
+ - Fixing test\unit\adapters\http.js lint errors
59
+ - Adding test for disabling auto decompression
60
+ - Removing changes that fixed lint errors in tests
61
+ - Removing formating change to unit test
62
+ - Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781))
63
+ - Add independent option to set the maximum size of the request body
64
+ - Remove maxBodyLength check
65
+ - Update README
66
+ - Assert for error code and message
67
+ - Adding responseEncoding to mergeConfig ([#1745](https://github.com/axios/axios/pull/1745))
68
+ - Compatible with follow-redirect aborts the request ([#2689](https://github.com/axios/axios/pull/2689))
69
+ - Compatible with follow-redirect aborts the request
70
+ - Use the error code
71
+ - Fix merging of params ([#2656](https://github.com/axios/axios/pull/2656))
72
+ - Name function to avoid ESLint func-names warning
73
+ - Switch params config to merge list and update tests
74
+ - Restore testing of both false and null
75
+ - Restore test cases for keys without defaults
76
+ - Include test for non-object values that aren't false-y.
77
+ - Revert `finally` as `then` ([#2683](https://github.com/axios/axios/pull/2683))
78
+
79
+ Internal and Tests:
80
+
81
+ - Fix stale bot config ([#3049](https://github.com/axios/axios/pull/3049))
82
+ - fix stale bot config
83
+ - fix multiple lines
84
+ - Add days and change name to work ([#3035](https://github.com/axios/axios/pull/3035))
85
+ - Update close-issues.yml ([#3031](https://github.com/axios/axios/pull/3031))
86
+ - Update close-issues.yml
87
+ Update close message to read better 😄
88
+ - Fix use of quotations
89
+ Use single quotes as per other .yml files
90
+ - Remove user name form message
91
+ - Add GitHub actions to close stale issues/prs ([#3029](https://github.com/axios/axios/pull/3029))
92
+ - prepare stale actions
93
+ - update messages
94
+ - Add exempt labels and lighten up comments
95
+ - Add GitHub actions to close invalid issues ([#3022](https://github.com/axios/axios/pull/3022))
96
+ - add close actions
97
+ - fix with checkout
98
+ - update issue templates
99
+ - add reminder
100
+ - update close message
101
+ - Add test with Node.js 12 ([#2860](https://github.com/axios/axios/pull/2860))
102
+ - test with Node.js 12
103
+ - test with latest
104
+ - Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210))
105
+ - Adding console log on sandbox server startup
106
+ - Update server.js
107
+ Add server error handeling
108
+ - Update server.js
109
+ Better error message, remove retry.
110
+ - Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996))
111
+ Update tests.
112
+ - Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695))
113
+ - Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601))
114
+ - Fixing issue for HEAD method and gziped repsonse ([#2666](https://github.com/axios/axios/pull/2666))
115
+ - Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748))
116
+ - chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443))
117
+
118
+ Documentation:
119
+
120
+ - Adding support for URLSearchParams in node ([#1900](https://github.com/axios/axios/pull/1900))
121
+ - Adding support for URLSearchParams in node
122
+ - Remove un-needed code
123
+ - Update utils.js
124
+ - Make changes as suggested
125
+ - Adding table of content (preview) ([#3050](https://github.com/axios/axios/pull/3050))
126
+ - add toc (preview)
127
+ - remove toc in toc
128
+ Signed-off-by: Moni <usmoni@gmail.com>
129
+ - fix sublinks
130
+ - fix indentation
131
+ - remove redundant table links
132
+ - update caps and indent
133
+ - remove axios
134
+ - Replace 'blacklist' with 'blocklist' ([#3006](https://github.com/axios/axios/pull/3006))
135
+ - docs(): Detailed config options environment. ([#2088](https://github.com/axios/axios/pull/2088))
136
+ - docs(): Detailed config options environment.
137
+ - Update README.md
138
+ - Include axios-data-unpacker in ECOSYSTEM.md ([#2080](https://github.com/axios/axios/pull/2080))
139
+ - Allow opening examples in Gitpod ([#1958](https://github.com/axios/axios/pull/1958))
140
+ - Remove axios.all() and axios.spread() from Readme.md ([#2727](https://github.com/axios/axios/pull/2727))
141
+ - remove axios.all(), axios.spread()
142
+ - replace example
143
+ - axios.all() -> Promise.all()
144
+ - axios.spread(function (acct, perms)) -> function (acct, perms)
145
+ - add deprecated mark
146
+ - Update README.md ([#2887](https://github.com/axios/axios/pull/2887))
147
+ 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.
148
+ - Include swagger-taxos-codegen in ECOSYSTEM.md ([#2162](https://github.com/axios/axios/pull/2162))
149
+ - Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878))
150
+ This badge will show the version on CDNJS!
151
+ - Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928))
152
+ - Made a adjustment to the documenation 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.
153
+ - Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912))
154
+ 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"
155
+ - Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805))
156
+ Closes #2049
157
+ - Fixing CHANGELOG.md issue link ([#2784](https://github.com/axios/axios/pull/2784))
158
+ - Include axios-hooks in ECOSYSTEM.md ([#2003](https://github.com/axios/axios/pull/2003))
159
+ - Added Response header access instructions ([#1901](https://github.com/axios/axios/pull/1901))
160
+ - Added Response header access instructions
161
+ - Added note about using bracket notation
162
+ - Add `onUploadProgress` and `onDownloadProgress` are browser only ([#2763](https://github.com/axios/axios/pull/2763))
163
+ Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README.
164
+ - Update ' sign to ` in proxy spec ([#2778](https://github.com/axios/axios/pull/2778))
165
+ - Adding jsDelivr link in README ([#1110](https://github.com/axios/axios/pull/1110))
166
+ - Adding jsDelivr link
167
+ - Add SRI
168
+ - Remove SRI
169
+
170
+ Huge thanks to everyone who contributed to this release via code (authors listed
171
+ below) or via reviews and triaging on GitHub:
172
+
173
+ - Alan Wang <wp_scut@163.com>
174
+ - Alexandru Ungureanu <khakcarot@gmail.com>
175
+ - Anubhav Srivastava <anubhav.srivastava00@gmail.com>
176
+ - Benny Neugebauer <bn@bennyn.de>
177
+ - Cr <631807682@qq.com>
178
+ - David <cygnidavid@gmail.com>
179
+ - David Ko <david.ko@pvtmethod.com>
180
+ - David Tanner <david.tanner@lifeomic.com>
181
+ - Emily Morehouse <emilyemorehouse@gmail.com>
182
+ - Felipe Martins <felipewmartins@gmail.com>
183
+ - Fonger <5862369+Fonger@users.noreply.github.com>
184
+ - Frostack <soulburn007@gmail.com>
185
+ - George Cheng <Gerhut@GMail.com>
186
+ - grumblerchester <grumblerchester@users.noreply.github.com>
187
+ - Gustavo López <gualopezb@gmail.com>
188
+ - hexaez <45806662+hexaez@users.noreply.github.com>
189
+ - huangzuizui <huangzuizui@gmail.com>
190
+ - Ian Wijma <ian@wij.ma>
191
+ - Jay <jasonsaayman@gmail.com>
192
+ - jeffjing <zgayjjf@qq.com>
193
+ - jennynju <46782518+jennynju@users.noreply.github.com>
194
+ - Jimmy Liao <52391190+jimmy-liao-gogoro@users.noreply.github.com>
195
+ - Jonathan Sharpe <j.r.sharpe@gmail.com>
196
+ - JounQin <admin@1stg.me>
197
+ - Justin Beckwith <justin.beckwith@gmail.com>
198
+ - Kamil Posiadała <3dcreator.pl@gmail.com>
199
+ - Lukas Drgon <lukas.drgon@gmail.com>
200
+ - marcinx <mail@marcinx.com>
201
+ - Martti Laine <martti@codeclown.net>
202
+ - Michał Zarach <michal.m.zarach@gmail.com>
203
+ - Moni <usmoni@gmail.com>
204
+ - Motonori Iwata <121048+iwata@users.noreply.github.com>
205
+ - Nikita Galkin <nikita@galk.in>
206
+ - Petr Mares <petr@mares.tw>
207
+ - Philippe Recto <precto1285@gmal.com>
208
+ - Remco Haszing <remcohaszing@gmail.com>
209
+ - rockcs1992 <chengshi1219@gmail.com>
210
+ - Ryan Bown <rbown@niftee.com.au>
211
+ - Samina Fu <sufuf3@gmail.com>
212
+ - Simone Busoli <simone.busoli@gmail.com>
213
+ - Spencer von der Ohe <s.vonderohe40@gmail.com>
214
+ - Sven Efftinge <sven.efftinge@typefox.io>
215
+ - Taegyeoung Oh <otk1090@naver.com>
216
+ - Taemin Shin <cprayer13@gmail.com>
217
+ - Thibault Ehrhart <1208424+ehrhart@users.noreply.github.com>
218
+ - Xianming Zhong <chinesedfan@qq.com>
219
+ - Yasu Flores <carlosyasu91@gmail.com>
220
+ - Zac Delventhal <delventhalz@gmail.com>
221
+
222
+ ### 0.19.2 (Jan 20, 2020)
223
+
224
+ - Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion)
225
+
226
+ ### 0.19.1 (Jan 7, 2020)
227
+
228
+ Fixes and Functionality:
229
+
230
+ - Fixing invalid agent issue ([#1904](https://github.com/axios/axios/pull/1904))
231
+ - Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582))
232
+ - Delete useless default to hash ([#2458](https://github.com/axios/axios/pull/2458))
233
+ - Fix HTTP/HTTPs agents passing to follow-redirect ([#1904](https://github.com/axios/axios/pull/1904))
234
+ - Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582))
235
+ - Fix CI build failure ([#2570](https://github.com/axios/axios/pull/2570))
236
+ - Remove dependency on is-buffer from package.json ([#1816](https://github.com/axios/axios/pull/1816))
237
+ - Adding options typings ([#2341](https://github.com/axios/axios/pull/2341))
238
+ - Adding Typescript HTTP method definition for LINK and UNLINK. ([#2444](https://github.com/axios/axios/pull/2444))
239
+ - Update dist with newest changes, fixes Custom Attributes issue
240
+ - Change syntax to see if build passes ([#2488](https://github.com/axios/axios/pull/2488))
241
+ - Update Webpack + deps, remove now unnecessary polyfills ([#2410](https://github.com/axios/axios/pull/2410))
242
+ - Fix to prevent XSS, throw an error when the URL contains a JS script ([#2464](https://github.com/axios/axios/pull/2464))
243
+ - Add custom timeout error copy in config ([#2275](https://github.com/axios/axios/pull/2275))
244
+ - Add error toJSON example ([#2466](https://github.com/axios/axios/pull/2466))
245
+ - Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… ([#2451](https://github.com/axios/axios/pull/2451))
246
+ - Fixing subdomain handling on no_proxy ([#2442](https://github.com/axios/axios/pull/2442))
247
+ - Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426)) and ([#2547](https://github.com/axios/axios/pull/2547))
248
+ - Add toJSON property to AxiosError type ([#2427](https://github.com/axios/axios/pull/2427))
249
+ - Fixing socket hang up error on node side for slow response. ([#1752](https://github.com/axios/axios/pull/1752))
250
+ - Alternative syntax to send data into the body ([#2317](https://github.com/axios/axios/pull/2317))
251
+ - Fixing custom config options ([#2207](https://github.com/axios/axios/pull/2207))
252
+ - Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383))
253
+ - Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290))
254
+ - 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))
255
+ - Add typescript HTTP method definition for LINK and UNLINK ([#2444](https://github.com/axios/axios/pull/2444))
256
+
257
+ Internal:
258
+
259
+ - Revert "Update Webpack + deps, remove now unnecessary polyfills" ([#2479](https://github.com/axios/axios/pull/2479))
260
+ - Order of if/else blocks is causing unit tests mocking XHR. ([#2201](https://github.com/axios/axios/pull/2201))
261
+ - Add license badge ([#2446](https://github.com/axios/axios/pull/2446))
262
+ - Fix travis CI build [#2386](https://github.com/axios/axios/pull/2386)
263
+ - Fix cancellation error on build master. #2290 #2207 ([#2407](https://github.com/axios/axios/pull/2407))
264
+
265
+ Documentation:
266
+
267
+ - Fixing typo in CHANGELOG.md: s/Functionallity/Functionality ([#2639](https://github.com/axios/axios/pull/2639))
268
+ - Fix badge, use master branch ([#2538](https://github.com/axios/axios/pull/2538))
269
+ - Fix typo in changelog [#2193](https://github.com/axios/axios/pull/2193)
270
+ - Document fix ([#2514](https://github.com/axios/axios/pull/2514))
271
+ - Update docs with no_proxy change, issue #2484 ([#2513](https://github.com/axios/axios/pull/2513))
272
+ - Fixing missing words in docs template ([#2259](https://github.com/axios/axios/pull/2259))
273
+ - 🐛Fix request finally documentation in README ([#2189](https://github.com/axios/axios/pull/2189))
274
+ - updating spelling and adding link to docs ([#2212](https://github.com/axios/axios/pull/2212))
275
+ - docs: minor tweak ([#2404](https://github.com/axios/axios/pull/2404))
276
+ - Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399))
277
+ - Update README.md ([#2504](https://github.com/axios/axios/pull/2504))
278
+ - Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432))
279
+ - upadating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
280
+ - Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271))
281
+ - Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198))
282
+
3
283
  ### 0.19.0 (May 30, 2019)
4
284
 
5
285
  Fixes and Functionality:
6
286
 
287
+ - Added support for no_proxy env variable ([#1693](https://github.com/axios/axios/pull/1693/files)) - Chance Dickson
7
288
  - Unzip response body only for statuses != 204 ([#1129](https://github.com/axios/axios/pull/1129)) - drawski
8
- - Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issue/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev
289
+ - Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issues/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev
9
290
  - Makes Axios error generic to use AxiosResponse ([#1738](https://github.com/axios/axios/pull/1738)) - Suman Lama
10
291
  - Fixing Mocha tests by locking follow-redirects version to 1.5.10 ([#1993](https://github.com/axios/axios/pull/1993)) - grumblerchester
11
292
  - Allow uppercase methods in typings. ([#1781](https://github.com/axios/axios/pull/1781)) - Ken Powers
12
- - Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel
13
- - Consistent coding style ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez
14
293
  - Fixing building url with hash mark ([#1771](https://github.com/axios/axios/pull/1771)) - Anatoly Ryabov
15
294
  - This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after `#`, because client cut everything after `#`
16
295
  - Preserve HTTP method when following redirect ([#1758](https://github.com/axios/axios/pull/1758)) - Rikki Gibson
17
296
  - Add `getUri` signature to TypeScript definition. ([#1736](https://github.com/axios/axios/pull/1736)) - Alexander Trauzzi
18
297
  - Adding isAxiosError flag to errors thrown by axios ([#1419](https://github.com/axios/axios/pull/1419)) - Ayush Gupta
298
+
299
+ Internal:
300
+
301
+ - Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel
19
302
  - Fix failing SauceLabs tests by updating configuration - Emily Morehouse
303
+ - Add issue templates - Emily Morehouse
20
304
 
21
305
  Documentation:
22
306
 
307
+ - Consistent coding style in README ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez
23
308
  - Add information about auth parameter to README ([#2166](https://github.com/axios/axios/pull/2166)) - xlaguna
24
309
  - Add DELETE to list of methods that allow data as a config option ([#2169](https://github.com/axios/axios/pull/2169)) - Daniela Borges Matos de Carvalho
25
310
  - Update ECOSYSTEM.md - Add Axios Endpoints ([#2176](https://github.com/axios/axios/pull/2176)) - Renan
@@ -30,7 +315,6 @@ Documentation:
30
315
  - Clarify what values responseType can have in Node ([#2121](https://github.com/axios/axios/pull/2121)) - Tyler Breisacher
31
316
  - docs(ECOSYSTEM): add axios-api-versioning ([#2020](https://github.com/axios/axios/pull/2020)) - Weffe
32
317
  - It seems that `responseType: 'blob'` doesn't actually work in Node (when I tried using it, response.data was a string, not a Blob, since Node doesn't have Blobs), so this clarifies that this option should only be used in the browser
33
- - Add issue templates - Emily Morehouse
34
318
  - Update README.md. - Add Querystring library note ([#1896](https://github.com/axios/axios/pull/1896)) - Dmitriy Eroshenko
35
319
  - Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan
36
320
  - Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # axios
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
4
- [![build status](https://img.shields.io/travis/axios/axios.svg?style=flat-square)](https://travis-ci.org/axios/axios)
4
+ [![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
5
+ [![build status](https://img.shields.io/travis/axios/axios/master.svg?style=flat-square)](https://travis-ci.org/axios/axios)
5
6
  [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
6
7
  [![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
7
8
  [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
@@ -9,6 +10,37 @@
9
10
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](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 cdn:
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>
@@ -57,6 +95,15 @@ Using cdn:
57
95
 
58
96
  ## Example
59
97
 
98
+ ### note: CommonJS usage
99
+ In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach:
100
+
101
+ ```js
102
+ const axios = require('axios').default;
103
+
104
+ // axios.<method> will now provide autocomplete and parameter typings
105
+ ```
106
+
60
107
  Performing a `GET` request
61
108
 
62
109
  ```js
@@ -72,7 +119,7 @@ axios.get('/user?ID=12345')
72
119
  // handle error
73
120
  console.log(error);
74
121
  })
75
- .finally(function () {
122
+ .then(function () {
76
123
  // always executed
77
124
  });
78
125
 
@@ -132,10 +179,11 @@ function getUserPermissions() {
132
179
  return axios.get('/user/12345/permissions');
133
180
  }
134
181
 
135
- axios.all([getUserAccount(), getUserPermissions()])
136
- .then(axios.spread(function (acct, perms) {
137
- // Both requests are now complete
138
- }));
182
+ Promise.all([getUserAccount(), getUserPermissions()])
183
+ .then(function (results) {
184
+ const acct = results[0];
185
+ const perm = results[1];
186
+ });
139
187
  ```
140
188
 
141
189
  ## axios API
@@ -157,7 +205,7 @@ axios({
157
205
  ```
158
206
 
159
207
  ```js
160
- // GET request for remote image
208
+ // GET request for remote image in node.js
161
209
  axios({
162
210
  method: 'get',
163
211
  url: 'http://bit.ly/2mTM3nY',
@@ -191,12 +239,13 @@ For convenience aliases have been provided for all supported request methods.
191
239
  ###### NOTE
192
240
  When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
193
241
 
194
- ### Concurrency
242
+ ### Concurrency (Deprecated)
243
+ Please use `Promise.all` to replace the below functions.
195
244
 
196
245
  Helper functions for dealing with concurrent requests.
197
246
 
198
- ##### axios.all(iterable)
199
- ##### axios.spread(callback)
247
+ axios.all(iterable)
248
+ axios.spread(callback)
200
249
 
201
250
  ### Creating an instance
202
251
 
@@ -278,7 +327,7 @@ These are the available config options for making requests. Only the `url` is re
278
327
  },
279
328
 
280
329
  // `data` is the data to be sent as the request body
281
- // Only applicable for request methods 'PUT', 'POST', and 'PATCH'
330
+ // Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
282
331
  // When no `transformRequest` is set, must be of one of the following types:
283
332
  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
284
333
  // - Browser only: FormData, File, Blob
@@ -286,6 +335,11 @@ These are the available config options for making requests. Only the `url` is re
286
335
  data: {
287
336
  firstName: 'Fred'
288
337
  },
338
+
339
+ // syntax alternative to send data into the body
340
+ // method post
341
+ // only the value is sent, not the key
342
+ data: 'Country=Brasil&City=Belo Horizonte',
289
343
 
290
344
  // `timeout` specifies the number of milliseconds before the request times out.
291
345
  // If the request takes longer than `timeout`, the request will be aborted.
@@ -316,7 +370,7 @@ These are the available config options for making requests. Only the `url` is re
316
370
  // browser only: 'blob'
317
371
  responseType: 'json', // default
318
372
 
319
- // `responseEncoding` indicates encoding to use for decoding responses
373
+ // `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
320
374
  // Note: Ignored for `responseType` of 'stream' or client-side requests
321
375
  responseEncoding: 'utf8', // default
322
376
 
@@ -327,18 +381,23 @@ These are the available config options for making requests. Only the `url` is re
327
381
  xsrfHeaderName: 'X-XSRF-TOKEN', // default
328
382
 
329
383
  // `onUploadProgress` allows handling of progress events for uploads
384
+ // browser only
330
385
  onUploadProgress: function (progressEvent) {
331
386
  // Do whatever you want with the native progress event
332
387
  },
333
388
 
334
389
  // `onDownloadProgress` allows handling of progress events for downloads
390
+ // browser only
335
391
  onDownloadProgress: function (progressEvent) {
336
392
  // Do whatever you want with the native progress event
337
393
  },
338
394
 
339
- // `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
340
396
  maxContentLength: 2000,
341
397
 
398
+ // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
399
+ maxBodyLength: 2000,
400
+
342
401
  // `validateStatus` defines whether to resolve or reject the promise for a given
343
402
  // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
344
403
  // or `undefined`), the promise will be resolved; otherwise, the promise will be
@@ -363,7 +422,7 @@ These are the available config options for making requests. Only the `url` is re
363
422
  httpAgent: new http.Agent({ keepAlive: true }),
364
423
  httpsAgent: new https.Agent({ keepAlive: true }),
365
424
 
366
- // 'proxy' defines the hostname and port of the proxy server.
425
+ // `proxy` defines the hostname and port of the proxy server.
367
426
  // You can also define your proxy using the conventional `http_proxy` and
368
427
  // `https_proxy` environment variables. If you are using environment variables
369
428
  // for your proxy configuration, you can also define a `no_proxy` environment
@@ -385,7 +444,14 @@ These are the available config options for making requests. Only the `url` is re
385
444
  // `cancelToken` specifies a cancel token that can be used to cancel the request
386
445
  // (see Cancellation section below for details)
387
446
  cancelToken: new CancelToken(function (cancel) {
388
- })
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
+
389
455
  }
390
456
  ```
391
457
 
@@ -404,8 +470,9 @@ The response for a request contains the following information.
404
470
  // `statusText` is the HTTP status message from the server response
405
471
  statusText: 'OK',
406
472
 
407
- // `headers` the headers that the server responded with
408
- // 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']`
409
476
  headers: {},
410
477
 
411
478
  // `config` is the config that was provided to `axios` for the request
@@ -413,7 +480,7 @@ The response for a request contains the following information.
413
480
 
414
481
  // `request` is the request that generated this response
415
482
  // It is the last ClientRequest instance in node.js (in redirects)
416
- // and an XMLHttpRequest instance the browser
483
+ // and an XMLHttpRequest instance in the browser
417
484
  request: {}
418
485
  }
419
486
  ```
@@ -492,15 +559,17 @@ axios.interceptors.request.use(function (config) {
492
559
 
493
560
  // Add a response interceptor
494
561
  axios.interceptors.response.use(function (response) {
562
+ // Any status code that lie within the range of 2xx cause this function to trigger
495
563
  // Do something with response data
496
564
  return response;
497
565
  }, function (error) {
566
+ // Any status codes that falls outside the range of 2xx cause this function to trigger
498
567
  // Do something with response error
499
568
  return Promise.reject(error);
500
569
  });
501
570
  ```
502
571
 
503
- If you may need to remove an interceptor later you can.
572
+ If you need to remove an interceptor later you can.
504
573
 
505
574
  ```js
506
575
  const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
@@ -538,16 +607,25 @@ axios.get('/user/12345')
538
607
  });
539
608
  ```
540
609
 
541
- You can define a custom HTTP status code error range using the `validateStatus` config option.
610
+ Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error.
542
611
 
543
612
  ```js
544
613
  axios.get('/user/12345', {
545
614
  validateStatus: function (status) {
546
- return status < 500; // Reject only if the status code is greater than or equal to 500
615
+ return status < 500; // Resolve only if the status code is less than 500
547
616
  }
548
617
  })
549
618
  ```
550
619
 
620
+ Using `toJSON` you get an object with more information about the HTTP error.
621
+
622
+ ```js
623
+ axios.get('/user/12345')
624
+ .catch(function (error) {
625
+ console.log(error.toJSON());
626
+ });
627
+ ```
628
+
551
629
  ## Cancellation
552
630
 
553
631
  You can cancel a request using a *cancel token*.
@@ -639,6 +717,8 @@ axios(options);
639
717
 
640
718
  ### Node.js
641
719
 
720
+ #### Query string
721
+
642
722
  In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
643
723
 
644
724
  ```js
@@ -646,11 +726,45 @@ const querystring = require('querystring');
646
726
  axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
647
727
  ```
648
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
+
649
737
  You can also use the [`qs`](https://github.com/ljharb/qs) library.
650
738
 
651
739
  ###### NOTE
652
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).
653
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
+
654
768
  ## Semver
655
769
 
656
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.
@@ -681,4 +795,4 @@ axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/
681
795
 
682
796
  ## License
683
797
 
684
- MIT
798
+ [MIT](LICENSE)