axios 0.19.2 → 0.21.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 CHANGED
@@ -1,5 +1,277 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.21.1 (December 21, 2020)
4
+
5
+ Fixes and Functionality:
6
+
7
+ - Hotfix: Prevent SSRF (#3410)
8
+ - Protocol not parsed when setting proxy config from env vars (#3070)
9
+ - Updating axios in types to be lower case (#2797)
10
+ - Adding a type guard for `AxiosError` (#2949)
11
+
12
+ Internal and Tests:
13
+
14
+ - Remove the skipping of the `socket` http test (#3364)
15
+ - Use different socket for Win32 test (#3375)
16
+
17
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
18
+
19
+ - Daniel Lopretto <timemachine3030@users.noreply.github.com>
20
+ - Jason Kwok <JasonHK@users.noreply.github.com>
21
+ - Jay <jasonsaayman@gmail.com>
22
+ - Jonathan Foster <jonathan@jonathanfoster.io>
23
+ - Remco Haszing <remcohaszing@gmail.com>
24
+ - Xianming Zhong <chinesedfan@qq.com>
25
+
26
+ ### 0.21.0 (October 23, 2020)
27
+
28
+ Fixes and Functionality:
29
+
30
+ - Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287))
31
+ - Fixing node types ([#3237](https://github.com/axios/axios/pull/3237))
32
+ - Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282))
33
+ - Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289))
34
+ - 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))
35
+
36
+ Internal and Tests:
37
+
38
+ - Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361))
39
+
40
+ Documentation:
41
+
42
+ - Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252))
43
+ - Fixing typos ([#3309](https://github.com/axios/axios/pull/3309))
44
+
45
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
46
+
47
+ - Allan Cruz <57270969+Allanbcruz@users.noreply.github.com>
48
+ - George Cheng <Gerhut@GMail.com>
49
+ - Jay <jasonsaayman@gmail.com>
50
+ - Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
51
+ - Remco Haszing <remcohaszing@gmail.com>
52
+ - Taemin Shin <cprayer13@gmail.com>
53
+ - Tim Gates <tim.gates@iress.com>
54
+ - Xianming Zhong <chinesedfan@qq.com>
55
+
56
+ ### 0.20.0 (August 20, 2020)
57
+
58
+ Release of 0.20.0-pre as a full release with no other changes.
59
+
60
+ ### 0.20.0-pre (July 15, 2020)
61
+
62
+ Fixes and Functionality:
63
+
64
+ - Fixing response with utf-8 BOM can not parse to json ([#2419](https://github.com/axios/axios/pull/2419))
65
+ - fix: remove byte order marker (UTF-8 BOM) when transform response
66
+ - fix: remove BOM only utf-8
67
+ - test: utf-8 BOM
68
+ - fix: incorrect param name
69
+ - Refactor mergeConfig without utils.deepMerge ([#2844](https://github.com/axios/axios/pull/2844))
70
+ - Adding failing test
71
+ - Fixing #2587 default custom config persisting
72
+ - Adding Concat keys and filter duplicates
73
+ - Fixed value from CPE
74
+ - update for review feedbacks
75
+ - no deepMerge
76
+ - only merge between plain objects
77
+ - fix rename
78
+ - always merge config by mergeConfig
79
+ - extract function mergeDeepProperties
80
+ - refactor mergeConfig with all keys, and add special logic for validateStatus
81
+ - add test for resetting headers
82
+ - add lots of tests and fix a bug
83
+ - should not inherit `data`
84
+ - use simple toString
85
+ - Fixing overwrite Blob/File type as Content-Type in browser. ([#1773](https://github.com/axios/axios/pull/1773))
86
+ - Fixing an issue that type 'null' is not assignable to validateStatus ([#2773](https://github.com/axios/axios/pull/2773))
87
+ - Fixing special char encoding ([#1671](https://github.com/axios/axios/pull/1671))
88
+ - removing @ character from replacement list since it is a reserved character
89
+ - Updating buildURL test to not include the @ character
90
+ - Removing console logs
91
+ - Fixing password encoding with special characters in basic authentication ([#1492](https://github.com/axios/axios/pull/1492))
92
+ - Fixing password encoding with special characters in basic authentication
93
+ - Adding test to check if password with non-Latin1 characters pass
94
+ - Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
95
+ 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.
96
+ - Fixing Cookie Helper with Asyc Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
97
+ - Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
98
+ - Fix 'progressEvent' type
99
+ - Update axios.ts
100
+ - Fixing getting local files (file://) failed ([#2470](https://github.com/axios/axios/pull/2470))
101
+ - fix issue #2416, #2396
102
+ - fix Eslint warn
103
+ - Modify judgment conditions
104
+ - add unit test
105
+ - update unit test
106
+ - update unit test
107
+ - Allow PURGE method in typings ([#2191](https://github.com/axios/axios/pull/2191))
108
+ - Adding option to disable automatic decompression ([#2661](https://github.com/axios/axios/pull/2661))
109
+ - Adding ability to disable auto decompression
110
+ - Updating decompress documentation in README
111
+ - Fixing test\unit\adapters\http.js lint errors
112
+ - Adding test for disabling auto decompression
113
+ - Removing changes that fixed lint errors in tests
114
+ - Removing formatting change to unit test
115
+ - Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781))
116
+ - Add independent option to set the maximum size of the request body
117
+ - Remove maxBodyLength check
118
+ - Update README
119
+ - Assert for error code and message
120
+ - Adding responseEncoding to mergeConfig ([#1745](https://github.com/axios/axios/pull/1745))
121
+ - Compatible with follow-redirect aborts the request ([#2689](https://github.com/axios/axios/pull/2689))
122
+ - Compatible with follow-redirect aborts the request
123
+ - Use the error code
124
+ - Fix merging of params ([#2656](https://github.com/axios/axios/pull/2656))
125
+ - Name function to avoid ESLint func-names warning
126
+ - Switch params config to merge list and update tests
127
+ - Restore testing of both false and null
128
+ - Restore test cases for keys without defaults
129
+ - Include test for non-object values that aren't false-y.
130
+ - Revert `finally` as `then` ([#2683](https://github.com/axios/axios/pull/2683))
131
+
132
+ Internal and Tests:
133
+
134
+ - Fix stale bot config ([#3049](https://github.com/axios/axios/pull/3049))
135
+ - fix stale bot config
136
+ - fix multiple lines
137
+ - Add days and change name to work ([#3035](https://github.com/axios/axios/pull/3035))
138
+ - Update close-issues.yml ([#3031](https://github.com/axios/axios/pull/3031))
139
+ - Update close-issues.yml
140
+ Update close message to read better 😄
141
+ - Fix use of quotations
142
+ Use single quotes as per other .yml files
143
+ - Remove user name form message
144
+ - Add GitHub actions to close stale issues/prs ([#3029](https://github.com/axios/axios/pull/3029))
145
+ - prepare stale actions
146
+ - update messages
147
+ - Add exempt labels and lighten up comments
148
+ - Add GitHub actions to close invalid issues ([#3022](https://github.com/axios/axios/pull/3022))
149
+ - add close actions
150
+ - fix with checkout
151
+ - update issue templates
152
+ - add reminder
153
+ - update close message
154
+ - Add test with Node.js 12 ([#2860](https://github.com/axios/axios/pull/2860))
155
+ - test with Node.js 12
156
+ - test with latest
157
+ - Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210))
158
+ - Adding console log on sandbox server startup
159
+ - Update server.js
160
+ Add server error handling
161
+ - Update server.js
162
+ Better error message, remove retry.
163
+ - Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996))
164
+ Update tests.
165
+ - Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695))
166
+ - Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601))
167
+ - Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666))
168
+ - Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748))
169
+ - chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443))
170
+
171
+ Documentation:
172
+
173
+ - Adding support for URLSearchParams in node ([#1900](https://github.com/axios/axios/pull/1900))
174
+ - Adding support for URLSearchParams in node
175
+ - Remove un-needed code
176
+ - Update utils.js
177
+ - Make changes as suggested
178
+ - Adding table of content (preview) ([#3050](https://github.com/axios/axios/pull/3050))
179
+ - add toc (preview)
180
+ - remove toc in toc
181
+ Signed-off-by: Moni <usmoni@gmail.com>
182
+ - fix sublinks
183
+ - fix indentation
184
+ - remove redundant table links
185
+ - update caps and indent
186
+ - remove axios
187
+ - Replace 'blacklist' with 'blocklist' ([#3006](https://github.com/axios/axios/pull/3006))
188
+ - docs(): Detailed config options environment. ([#2088](https://github.com/axios/axios/pull/2088))
189
+ - docs(): Detailed config options environment.
190
+ - Update README.md
191
+ - Include axios-data-unpacker in ECOSYSTEM.md ([#2080](https://github.com/axios/axios/pull/2080))
192
+ - Allow opening examples in Gitpod ([#1958](https://github.com/axios/axios/pull/1958))
193
+ - Remove axios.all() and axios.spread() from Readme.md ([#2727](https://github.com/axios/axios/pull/2727))
194
+ - remove axios.all(), axios.spread()
195
+ - replace example
196
+ - axios.all() -> Promise.all()
197
+ - axios.spread(function (acct, perms)) -> function (acct, perms)
198
+ - add deprecated mark
199
+ - Update README.md ([#2887](https://github.com/axios/axios/pull/2887))
200
+ 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.
201
+ - Include swagger-taxos-codegen in ECOSYSTEM.md ([#2162](https://github.com/axios/axios/pull/2162))
202
+ - Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878))
203
+ This badge will show the version on CDNJS!
204
+ - Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928))
205
+ - 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.
206
+ - Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912))
207
+ 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"
208
+ - Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805))
209
+ Closes #2049
210
+ - Fixing CHANGELOG.md issue link ([#2784](https://github.com/axios/axios/pull/2784))
211
+ - Include axios-hooks in ECOSYSTEM.md ([#2003](https://github.com/axios/axios/pull/2003))
212
+ - Added Response header access instructions ([#1901](https://github.com/axios/axios/pull/1901))
213
+ - Added Response header access instructions
214
+ - Added note about using bracket notation
215
+ - Add `onUploadProgress` and `onDownloadProgress` are browser only ([#2763](https://github.com/axios/axios/pull/2763))
216
+ Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README.
217
+ - Update ' sign to ` in proxy spec ([#2778](https://github.com/axios/axios/pull/2778))
218
+ - Adding jsDelivr link in README ([#1110](https://github.com/axios/axios/pull/1110))
219
+ - Adding jsDelivr link
220
+ - Add SRI
221
+ - Remove SRI
222
+
223
+ Huge thanks to everyone who contributed to this release via code (authors listed
224
+ below) or via reviews and triaging on GitHub:
225
+
226
+ - Alan Wang <wp_scut@163.com>
227
+ - Alexandru Ungureanu <khakcarot@gmail.com>
228
+ - Anubhav Srivastava <anubhav.srivastava00@gmail.com>
229
+ - Benny Neugebauer <bn@bennyn.de>
230
+ - Cr <631807682@qq.com>
231
+ - David <cygnidavid@gmail.com>
232
+ - David Ko <david.ko@pvtmethod.com>
233
+ - David Tanner <david.tanner@lifeomic.com>
234
+ - Emily Morehouse <emilyemorehouse@gmail.com>
235
+ - Felipe Martins <felipewmartins@gmail.com>
236
+ - Fonger <5862369+Fonger@users.noreply.github.com>
237
+ - Frostack <soulburn007@gmail.com>
238
+ - George Cheng <Gerhut@GMail.com>
239
+ - grumblerchester <grumblerchester@users.noreply.github.com>
240
+ - Gustavo López <gualopezb@gmail.com>
241
+ - hexaez <45806662+hexaez@users.noreply.github.com>
242
+ - huangzuizui <huangzuizui@gmail.com>
243
+ - Ian Wijma <ian@wij.ma>
244
+ - Jay <jasonsaayman@gmail.com>
245
+ - jeffjing <zgayjjf@qq.com>
246
+ - jennynju <46782518+jennynju@users.noreply.github.com>
247
+ - Jimmy Liao <52391190+jimmy-liao-gogoro@users.noreply.github.com>
248
+ - Jonathan Sharpe <j.r.sharpe@gmail.com>
249
+ - JounQin <admin@1stg.me>
250
+ - Justin Beckwith <justin.beckwith@gmail.com>
251
+ - Kamil Posiadała <3dcreator.pl@gmail.com>
252
+ - Lukas Drgon <lukas.drgon@gmail.com>
253
+ - marcinx <mail@marcinx.com>
254
+ - Martti Laine <martti@codeclown.net>
255
+ - Michał Zarach <michal.m.zarach@gmail.com>
256
+ - Moni <usmoni@gmail.com>
257
+ - Motonori Iwata <121048+iwata@users.noreply.github.com>
258
+ - Nikita Galkin <nikita@galk.in>
259
+ - Petr Mares <petr@mares.tw>
260
+ - Philippe Recto <precto1285@gmal.com>
261
+ - Remco Haszing <remcohaszing@gmail.com>
262
+ - rockcs1992 <chengshi1219@gmail.com>
263
+ - Ryan Bown <rbown@niftee.com.au>
264
+ - Samina Fu <sufuf3@gmail.com>
265
+ - Simone Busoli <simone.busoli@gmail.com>
266
+ - Spencer von der Ohe <s.vonderohe40@gmail.com>
267
+ - Sven Efftinge <sven.efftinge@typefox.io>
268
+ - Taegyeoung Oh <otk1090@naver.com>
269
+ - Taemin Shin <cprayer13@gmail.com>
270
+ - Thibault Ehrhart <1208424+ehrhart@users.noreply.github.com>
271
+ - Xianming Zhong <chinesedfan@qq.com>
272
+ - Yasu Flores <carlosyasu91@gmail.com>
273
+ - Zac Delventhal <delventhalz@gmail.com>
274
+
3
275
  ### 0.19.2 (Jan 20, 2020)
4
276
 
5
277
  - Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion)
@@ -25,7 +297,7 @@ Fixes and Functionality:
25
297
  - Add error toJSON example ([#2466](https://github.com/axios/axios/pull/2466))
26
298
  - Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… ([#2451](https://github.com/axios/axios/pull/2451))
27
299
  - Fixing subdomain handling on no_proxy ([#2442](https://github.com/axios/axios/pull/2442))
28
- - Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426] and ([#2547](https://github.com/axios/axios/pull/2547))
300
+ - Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426)) and ([#2547](https://github.com/axios/axios/pull/2547))
29
301
  - Add toJSON property to AxiosError type ([#2427](https://github.com/axios/axios/pull/2427))
30
302
  - Fixing socket hang up error on node side for slow response. ([#1752](https://github.com/axios/axios/pull/1752))
31
303
  - Alternative syntax to send data into the body ([#2317](https://github.com/axios/axios/pull/2317))
@@ -57,7 +329,7 @@ Documentation:
57
329
  - Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399))
58
330
  - Update README.md ([#2504](https://github.com/axios/axios/pull/2504))
59
331
  - Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432))
60
- - upadating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
332
+ - updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
61
333
  - Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271))
62
334
  - Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198))
63
335
 
@@ -110,7 +382,7 @@ New Functionality:
110
382
 
111
383
  - Add getUri method ([#1712](https://github.com/axios/axios/issues/1712))
112
384
  - Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693))
113
- - Add toJSON to decorated Axios errors to faciliate serialization ([#1625](https://github.com/axios/axios/issues/1625))
385
+ - Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625))
114
386
  - Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623))
115
387
  - Typings: allow custom return types
116
388
  - 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
  [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
4
+ [![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
4
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)
@@ -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>
@@ -81,7 +119,7 @@ axios.get('/user?ID=12345')
81
119
  // handle error
82
120
  console.log(error);
83
121
  })
84
- .finally(function () {
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
- .finally(function () {
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
- axios.all([getUserAccount(), getUserPermissions()])
145
- .then(axios.spread(function (acct, perms) {
146
- // Both requests are now complete
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
- ##### axios.all(iterable)
208
- ##### axios.spread(callback)
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
- // 'proxy' defines the hostname and port of the proxy server.
425
+ // `proxy` defines the hostname, port, and protocol 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
@@ -387,7 +432,9 @@ These are the available config options for making requests. Only the `url` is re
387
432
  // supplies credentials.
388
433
  // This will set an `Proxy-Authorization` header, overwriting any existing
389
434
  // `Proxy-Authorization` custom headers you have set using `headers`.
435
+ // If the proxy server uses HTTPS, then you must set the protocol to `https`.
390
436
  proxy: {
437
+ protocol: 'https',
391
438
  host: '127.0.0.1',
392
439
  port: 9000,
393
440
  auth: {
@@ -399,7 +446,14 @@ These are the available config options for making requests. Only the `url` is re
399
446
  // `cancelToken` specifies a cancel token that can be used to cancel the request
400
447
  // (see Cancellation section below for details)
401
448
  cancelToken: new CancelToken(function (cancel) {
402
- })
449
+ }),
450
+
451
+ // `decompress` indicates whether or not the response body should be decompressed
452
+ // automatically. If set to `true` will also remove the 'content-encoding' header
453
+ // from the responses objects of all decompressed responses
454
+ // - Node only (XHR cannot turn off decompression)
455
+ decompress: true // default
456
+
403
457
  }
404
458
  ```
405
459
 
@@ -418,8 +472,9 @@ The response for a request contains the following information.
418
472
  // `statusText` is the HTTP status message from the server response
419
473
  statusText: 'OK',
420
474
 
421
- // `headers` the headers that the server responded with
422
- // All header names are lower cased
475
+ // `headers` the HTTP headers that the server responded with
476
+ // All header names are lower cased and can be accessed using the bracket notation.
477
+ // Example: `response.headers['content-type']`
423
478
  headers: {},
424
479
 
425
480
  // `config` is the config that was provided to `axios` for the request
@@ -559,7 +614,7 @@ Using the `validateStatus` config option, you can define HTTP code(s) that shoul
559
614
  ```js
560
615
  axios.get('/user/12345', {
561
616
  validateStatus: function (status) {
562
- return status < 500; // Reject only if the status code is greater than or equal to 500
617
+ return status < 500; // Resolve only if the status code is less than 500
563
618
  }
564
619
  })
565
620
  ```
@@ -664,6 +719,8 @@ axios(options);
664
719
 
665
720
  ### Node.js
666
721
 
722
+ #### Query string
723
+
667
724
  In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
668
725
 
669
726
  ```js
@@ -671,11 +728,45 @@ const querystring = require('querystring');
671
728
  axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
672
729
  ```
673
730
 
731
+ or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows:
732
+
733
+ ```js
734
+ const url = require('url');
735
+ const params = new url.URLSearchParams({ foo: 'bar' });
736
+ axios.post('http://something.com/', params.toString());
737
+ ```
738
+
674
739
  You can also use the [`qs`](https://github.com/ljharb/qs) library.
675
740
 
676
741
  ###### NOTE
677
742
  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
743
 
744
+ #### Form data
745
+
746
+ In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows:
747
+
748
+ ```js
749
+ const FormData = require('form-data');
750
+
751
+ const form = new FormData();
752
+ form.append('my_field', 'my value');
753
+ form.append('my_buffer', new Buffer(10));
754
+ form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
755
+
756
+ axios.post('https://example.com', form, { headers: form.getHeaders() })
757
+ ```
758
+
759
+ Alternatively, use an interceptor:
760
+
761
+ ```js
762
+ axios.interceptors.request.use(config => {
763
+ if (config.data instanceof FormData) {
764
+ Object.assign(config.headers, config.data.getHeaders());
765
+ }
766
+ return config;
767
+ });
768
+ ```
769
+
679
770
  ## Semver
680
771
 
681
772
  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 deprectated 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.
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')