axios 0.20.0 → 0.21.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,137 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.21.3 (September 4, 2021)
4
+
5
+ Fixes and Functionality:
6
+ - Fixing response interceptor not being called when request interceptor is attached ([#4013](https://github.com/axios/axios/pull/4013))
7
+
8
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
9
+
10
+ - [Jay](mailto:jasonsaayman@gmail.com)
11
+ - [Julian Hollmann](https://github.com/nerdbeere)
12
+
13
+ ### 0.21.2 (September 4, 2021)
14
+
15
+ Fixes and Functionality:
16
+
17
+ - Updating axios requests to be delayed by pre-emptive promise creation ([#2702](https://github.com/axios/axios/pull/2702))
18
+ - Adding "synchronous" and "runWhen" options to interceptors api ([#2702](https://github.com/axios/axios/pull/2702))
19
+ - Updating of transformResponse ([#3377](https://github.com/axios/axios/pull/3377))
20
+ - Adding ability to omit User-Agent header ([#3703](https://github.com/axios/axios/pull/3703))
21
+ - Adding multiple JSON improvements ([#3688](https://github.com/axios/axios/pull/3688), [#3763](https://github.com/axios/axios/pull/3763))
22
+ - Fixing quadratic runtime and extra memory usage when setting a maxContentLength ([#3738](https://github.com/axios/axios/pull/3738))
23
+ - Adding parseInt to config.timeout ([#3781](https://github.com/axios/axios/pull/3781))
24
+ - Adding custom return type support to interceptor ([#3783](https://github.com/axios/axios/pull/3783))
25
+ - Adding security fix for ReDoS vulnerability ([#3980](https://github.com/axios/axios/pull/3980))
26
+
27
+ Internal and Tests:
28
+
29
+ - Updating build dev dependancies ([#3401](https://github.com/axios/axios/pull/3401))
30
+ - Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538))
31
+ - Updating follow rediect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771))
32
+ - Updating karma sauce launcher to fix failing sauce tests ([#3712](https://github.com/axios/axios/pull/3712), [#3717](https://github.com/axios/axios/pull/3717))
33
+ - Updating content-type header for application/json to not contain charset field, according do RFC 8259 ([#2154](https://github.com/axios/axios/pull/2154))
34
+ - Fixing tests by bumping karma-sauce-launcher version ([#3813](https://github.com/axios/axios/pull/3813))
35
+ - Changing testing process from Travis CI to GitHub Actions ([#3938](https://github.com/axios/axios/pull/3938))
36
+
37
+ Documentation:
38
+
39
+ - Updating documentation around the use of `AUTH_TOKEN` with multiple domain endpoints ([#3539](https://github.com/axios/axios/pull/3539))
40
+ - Remove duplication of item in changelog ([#3523](https://github.com/axios/axios/pull/3523))
41
+ - Fixing gramatical errors ([#2642](https://github.com/axios/axios/pull/2642))
42
+ - Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567))
43
+ - Moving gitpod metion ([#2637](https://github.com/axios/axios/pull/2637))
44
+ - Adding new axios documentation website link ([#3681](https://github.com/axios/axios/pull/3681), [#3707](https://github.com/axios/axios/pull/3707))
45
+ - Updating documentation around dispatching requests ([#3772](https://github.com/axios/axios/pull/3772))
46
+ - Adding documentation for the type guard isAxiosError ([#3767](https://github.com/axios/axios/pull/3767))
47
+ - Adding explanation of cancel token ([#3803](https://github.com/axios/axios/pull/3803))
48
+ - Updating CI status badge ([#3953](https://github.com/axios/axios/pull/3953))
49
+ - Fixing errors with JSON documentation ([#3936](https://github.com/axios/axios/pull/3936))
50
+ - Fixing README typo under Request Config ([#3825](https://github.com/axios/axios/pull/3825))
51
+ - Adding axios-multi-api to the ecosystem file ([#3817](https://github.com/axios/axios/pull/3817))
52
+ - Adding SECURITY.md to properly disclose security vulnerabilities ([#3981](https://github.com/axios/axios/pull/3981))
53
+
54
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
55
+
56
+ - [Jay](mailto:jasonsaayman@gmail.com)
57
+ - [Sasha Korotkov](https://github.com/SashaKoro)
58
+ - [Daniel Lopretto](https://github.com/timemachine3030)
59
+ - [Mike Bishop](https://github.com/MikeBishop)
60
+ - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
61
+ - [Mark](https://github.com/bimbiltu)
62
+ - [Philipe Gouveia Paixão](https://github.com/piiih)
63
+ - [hippo](https://github.com/hippo2cat)
64
+ - [ready-research](https://github.com/ready-research)
65
+ - [Xianming Zhong](https://github.com/chinesedfan)
66
+ - [Christopher Chrapka](https://github.com/OJezu)
67
+ - [Brian Anglin](https://github.com/anglinb)
68
+ - [Kohta Ito](https://github.com/koh110)
69
+ - [Ali Clark](https://github.com/aliclark)
70
+ - [caikan](https://github.com/caikan)
71
+ - [Elina Gorshkova](https://github.com/elinagorshkova)
72
+ - [Ryota Ikezawa](https://github.com/paveg)
73
+ - [Nisar Hassan Naqvi](https://github.com/nisarhassan12)
74
+ - [Jake](https://github.com/codemaster138)
75
+ - [TagawaHirotaka](https://github.com/wafuwafu13)
76
+ - [Johannes Jarbratt](https://github.com/johachi)
77
+ - [Mo Sattler](https://github.com/MoSattler)
78
+ - [Sam Carlton](https://github.com/ThatGuySam)
79
+ - [Matt Czapliński](https://github.com/MattCCC)
80
+ - [Ziding Zhang](https://github.com/zidingz)
81
+
82
+ ### 0.21.1 (December 21, 2020)
83
+
84
+ Fixes and Functionality:
85
+
86
+ - Hotfix: Prevent SSRF ([#3410](https://github.com/axios/axios/pull/3410))
87
+ - Protocol not parsed when setting proxy config from env vars ([#3070](https://github.com/axios/axios/pull/3070))
88
+ - Updating axios in types to be lower case ([#2797](https://github.com/axios/axios/pull/2797))
89
+ - Adding a type guard for `AxiosError` ([#2949](https://github.com/axios/axios/pull/2949))
90
+
91
+ Internal and Tests:
92
+
93
+ - Remove the skipping of the `socket` http test ([#3364](https://github.com/axios/axios/pull/3364))
94
+ - Use different socket for Win32 test ([#3375](https://github.com/axios/axios/pull/3375))
95
+
96
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
97
+
98
+ - Daniel Lopretto <timemachine3030@users.noreply.github.com>
99
+ - Jason Kwok <JasonHK@users.noreply.github.com>
100
+ - Jay <jasonsaayman@gmail.com>
101
+ - Jonathan Foster <jonathan@jonathanfoster.io>
102
+ - Remco Haszing <remcohaszing@gmail.com>
103
+ - Xianming Zhong <chinesedfan@qq.com>
104
+
105
+ ### 0.21.0 (October 23, 2020)
106
+
107
+ Fixes and Functionality:
108
+
109
+ - Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287))
110
+ - Fixing node types ([#3237](https://github.com/axios/axios/pull/3237))
111
+ - Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282))
112
+ - Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289))
113
+ - 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))
114
+
115
+ Internal and Tests:
116
+
117
+ - Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361))
118
+
119
+ Documentation:
120
+
121
+ - Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252))
122
+ - Fixing typos ([#3309](https://github.com/axios/axios/pull/3309))
123
+
124
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
125
+
126
+ - Allan Cruz <57270969+Allanbcruz@users.noreply.github.com>
127
+ - George Cheng <Gerhut@GMail.com>
128
+ - Jay <jasonsaayman@gmail.com>
129
+ - Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
130
+ - Remco Haszing <remcohaszing@gmail.com>
131
+ - Taemin Shin <cprayer13@gmail.com>
132
+ - Tim Gates <tim.gates@iress.com>
133
+ - Xianming Zhong <chinesedfan@qq.com>
134
+
3
135
  ### 0.20.0 (August 20, 2020)
4
136
 
5
137
  Release of 0.20.0-pre as a full release with no other changes.
@@ -40,7 +172,7 @@ Fixes and Functionality:
40
172
  - Adding test to check if password with non-Latin1 characters pass
41
173
  - Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
42
174
  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))
175
+ - Fixing Cookie Helper with Async Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
44
176
  - Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
45
177
  - Fix 'progressEvent' type
46
178
  - Update axios.ts
@@ -58,7 +190,7 @@ Fixes and Functionality:
58
190
  - Fixing test\unit\adapters\http.js lint errors
59
191
  - Adding test for disabling auto decompression
60
192
  - Removing changes that fixed lint errors in tests
61
- - Removing formating change to unit test
193
+ - Removing formatting change to unit test
62
194
  - Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781))
63
195
  - Add independent option to set the maximum size of the request body
64
196
  - Remove maxBodyLength check
@@ -104,14 +236,14 @@ Internal and Tests:
104
236
  - Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210))
105
237
  - Adding console log on sandbox server startup
106
238
  - Update server.js
107
- Add server error handeling
239
+ Add server error handling
108
240
  - Update server.js
109
241
  Better error message, remove retry.
110
242
  - Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996))
111
243
  Update tests.
112
244
  - Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695))
113
245
  - 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))
246
+ - Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666))
115
247
  - Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748))
116
248
  - chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443))
117
249
 
@@ -149,7 +281,7 @@ Documentation:
149
281
  - Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878))
150
282
  This badge will show the version on CDNJS!
151
283
  - 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.
284
+ - 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.
153
285
  - Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912))
154
286
  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
287
  - Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805))
@@ -252,7 +384,6 @@ Fixes and Functionality:
252
384
  - Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383))
253
385
  - Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290))
254
386
  - 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
387
 
257
388
  Internal:
258
389
 
@@ -276,7 +407,7 @@ Documentation:
276
407
  - Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399))
277
408
  - Update README.md ([#2504](https://github.com/axios/axios/pull/2504))
278
409
  - 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))
410
+ - updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256))
280
411
  - Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271))
281
412
  - Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198))
282
413
 
@@ -329,7 +460,7 @@ New Functionality:
329
460
 
330
461
  - Add getUri method ([#1712](https://github.com/axios/axios/issues/1712))
331
462
  - Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693))
332
- - Add toJSON to decorated Axios errors to faciliate serialization ([#1625](https://github.com/axios/axios/issues/1625))
463
+ - Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625))
333
464
  - Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623))
334
465
  - Typings: allow custom return types
335
466
  - Add option to specify character set in responses (with http adapter)
package/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
4
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
+ ![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg)
6
+ [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios)
6
7
  [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
7
8
  [![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
8
9
  [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
@@ -10,6 +11,9 @@
10
11
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
11
12
 
12
13
  Promise based HTTP client for the browser and node.js
14
+
15
+ > New axios docs website: [click here](https://axios-http.com/)
16
+
13
17
  ## Table of Contents
14
18
 
15
19
  - [Features](#features)
@@ -422,7 +426,7 @@ These are the available config options for making requests. Only the `url` is re
422
426
  httpAgent: new http.Agent({ keepAlive: true }),
423
427
  httpsAgent: new https.Agent({ keepAlive: true }),
424
428
 
425
- // `proxy` defines the hostname and port of the proxy server.
429
+ // `proxy` defines the hostname, port, and protocol of the proxy server.
426
430
  // You can also define your proxy using the conventional `http_proxy` and
427
431
  // `https_proxy` environment variables. If you are using environment variables
428
432
  // for your proxy configuration, you can also define a `no_proxy` environment
@@ -432,7 +436,9 @@ These are the available config options for making requests. Only the `url` is re
432
436
  // supplies credentials.
433
437
  // This will set an `Proxy-Authorization` header, overwriting any existing
434
438
  // `Proxy-Authorization` custom headers you have set using `headers`.
439
+ // If the proxy server uses HTTPS, then you must set the protocol to `https`.
435
440
  proxy: {
441
+ protocol: 'https',
436
442
  host: '127.0.0.1',
437
443
  port: 9000,
438
444
  auth: {
@@ -450,8 +456,21 @@ These are the available config options for making requests. Only the `url` is re
450
456
  // automatically. If set to `true` will also remove the 'content-encoding' header
451
457
  // from the responses objects of all decompressed responses
452
458
  // - Node only (XHR cannot turn off decompression)
453
- decompress: true // default
454
-
459
+ decompress: true, // default
460
+
461
+ // transitional options for backward compatibility that may be removed in the newer versions
462
+ transitional: {
463
+ // silent JSON parsing mode
464
+ // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
465
+ // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
466
+ silentJSONParsing: true, // default value for the current Axios version
467
+
468
+ // try to parse the response string as JSON even if `responseType` is not 'json'
469
+ forcedJSONParsing: true;
470
+
471
+ // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
472
+ clarifyTimeoutError: false,
473
+ }
455
474
  }
456
475
  ```
457
476
 
@@ -508,7 +527,11 @@ You can specify config defaults that will be applied to every request.
508
527
 
509
528
  ```js
510
529
  axios.defaults.baseURL = 'https://api.example.com';
530
+
531
+ // Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them.
532
+ // See below for an example using Custom instance defaults instead.
511
533
  axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
534
+
512
535
  axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
513
536
  ```
514
537
 
@@ -583,6 +606,34 @@ const instance = axios.create();
583
606
  instance.interceptors.request.use(function () {/*...*/});
584
607
  ```
585
608
 
609
+ When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay
610
+ in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
611
+ the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag
612
+ to the options object that will tell axios to run the code synchronously and avoid any delays in request execution.
613
+
614
+ ```js
615
+ axios.interceptors.request.use(function (config) {
616
+ config.headers.test = 'I am only a header!';
617
+ return config;
618
+ }, null, { synchronous: true });
619
+ ```
620
+
621
+ If you want to execute a particular interceptor based on a runtime check,
622
+ you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return
623
+ of `runWhen` is `false`. The function will be called with the config
624
+ object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
625
+ asynchronous request interceptor that only needs to run at certain times.
626
+
627
+ ```js
628
+ function onGetCall(config) {
629
+ return config.method === 'get';
630
+ }
631
+ axios.interceptors.request.use(function (config) {
632
+ config.headers.test = 'special get headers';
633
+ return config;
634
+ }, null, { runWhen: onGetCall });
635
+ ```
636
+
586
637
  ## Handling Errors
587
638
 
588
639
  ```js
@@ -676,6 +727,7 @@ cancel();
676
727
  ```
677
728
 
678
729
  > Note: you can cancel several requests with the same cancel token.
730
+ > If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make real request.
679
731
 
680
732
  ## Using application/x-www-form-urlencoded format
681
733
 
@@ -775,12 +827,30 @@ axios depends on a native ES6 Promise implementation to be [supported](http://ca
775
827
  If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
776
828
 
777
829
  ## TypeScript
778
- axios includes [TypeScript](http://typescriptlang.org) definitions.
830
+
831
+ axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors.
832
+
779
833
  ```typescript
780
- import axios from 'axios';
781
- axios.get('/user?ID=12345');
834
+ let user: User = null;
835
+ try {
836
+ const { data } = await axios.get('/user?ID=12345');
837
+ user = data.userDetails;
838
+ } catch (error) {
839
+ if (axios.isAxiosError(error)) {
840
+ handleAxiosError(error);
841
+ } else {
842
+ handleUnexpectedError(error);
843
+ }
844
+ }
782
845
  ```
783
846
 
847
+ ## Online one-click setup
848
+
849
+ You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online.
850
+
851
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js)
852
+
853
+
784
854
  ## Resources
785
855
 
786
856
  * [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please report security issues to jasonsaayman@gmail.com
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')