2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00
Commit Graph

234 Commits

Author SHA1 Message Date
Dmitriy Mozgovoy 0c3a1e9fde Refactored module exports; (#5162)
* Refactored build pipeline;
Added module exports tests;
Added missing ESM export for parity with Axios factory;
Added `toFormData`, `formToJSON`, `isAxiosError`, `spread`, `isCancel`, `all` as named export to `index.d.ts`;

* Added ESM entry test;

* Updated README.md `installing` section;

* Added TypeScript importing test;
Added missed `CanceledError` & `AxiosHeaders` to `AxiosStatic` interface;

* Exclude `/test/module/` from tslint;
2022-10-30 18:46:17 +02:00
ChronosMasterOfAllTime b0ebf9fcac Fix: Don't add null values to query string. (#5108)
* feat: add  boolean flag to mimic pre 1.x behavior for paramsSerializer custom function

* chore: update ParamsSerializer Readme

* fix: dont slice hash off URL if not appending params

* Omit nulls from formData serialization

* fix: dont add nulls or undefined values to arrays either

* readme update

* fix test

* chore: documentation

* chore: do TS properly

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-15 15:01:59 +02:00
Patrick Petrovic 717f476b0f fix: restore proxy config backwards compatibility with 0.x (#5097)
* fix: restore proxy config backwards compatibility with 0.x

* Formatting

Co-authored-by: Patrick Petrovic <patrick@Air-de-Patrick.lan>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 21:55:20 +02:00
Dmitriy Mozgovoy 83454a55f6 chore: added progress capturing section to the docs; (#5084)
Added rate limiting section to the docs;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 21:47:23 +02:00
Arvindh eedd9aafa5 chore: fixing comments typo (#5054)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 21:20:41 +02:00
Lenz Weber-Tronic 85740c3e7a pin CDN install instructions to a specific version (#5060) 2022-10-13 21:05:15 +02:00
scarf b733f36c2a docs: match badge style, add link to them (#5046)
codetriage and snyk could not be styled because the former does not have api; snyk api is charged.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-08 20:25:37 +02:00
Raihan Nismara aa001e2946 Using Logo Axios in Readme.md (#4993)
Using logo Axios in readme file made looks nicer
2022-10-04 19:48:11 +02:00
Huyen Nguyen 60e85533b3 docs: enable syntax highlighting for a code block (#4970)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-29 08:27:32 +02:00
Usman Ali Siddiqui 892c241773 Fix: typo in readme (#4942)
Co-authored-by: Usman Ali Siddiqui <usmanali.siddiqui@wsa.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-15 07:36:31 +02:00
Yue JIN 5138c302bb docs: fix Gitpod dead link (#4941)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-15 07:32:36 +02:00
Karl Horky d57fdb6510 Fix typo and formatting, add colons (#4853)
* Fix typo, add colons

* Fix code formatting

* Fix code formatting

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-15 07:21:40 +02:00
Grégoire Pineau dd5ba02254 Fix markup for note in README (#4825)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-14 21:32:23 +02:00
Dmitriy Mozgovoy bdf493cf8b Axios ES2017 (#4787)
* Added AxiosHeaders class;

* Fixed README.md href;

* Fixed a potential bug with headers normalization;

* Fixed a potential bug with headers normalization;
Refactored accessor building routine;
Refactored default transforms;
Removed `normalizeHeaderName` helper;

* Added `Content-Length` accessor;
Added missed `has` accessor to TS types;

* Added `AxiosTransformStream` class;
Added progress capturing ability for node.js environment;
Added `maxRate` option to limit the data rate in node.js environment;
Refactored event handled by `onUploadProgress` && `onDownloadProgress` listeners in browser environment;
Added progress & data rate tests for the http adapter;
Added response stream aborting test;
Added a manual progress capture test for the browser;
Updated TS types;
Added TS tests;
Refactored request abort logic for the http adapter;
Added ability to abort the response stream;

* Remove `stream/promises` & `timers/promises` modules usage in tests;

* Use `abortcontroller-polyfill`;

* Fixed AxiosTransformStream dead-lock in legacy node versions;
Fixed CancelError emitting in streams;

* Reworked AxiosTransformStream internal logic to optimize memory consumption;
Added throwing an error if the request stream was silently destroying (without error) Refers to #3966;

* Treat the destruction of the request stream as a cancellation of the request;
Fixed tests;

* Emit `progress` event in the next tick;

* Initial refactoring;

* Refactored Mocha tests to use ESM;

* Refactored Karma tests to use rollup preprocessor & ESM;
Replaced grunt with gulp;
Improved dev scripts;
Added Babel for rollup build;

* Added default commonjs package export for Node build;
Added automatic contributors list generator for package.json;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-06-18 11:19:27 +02:00
Dmitriy Mozgovoy a02fe284df Updated README.md; (#4742)
Updated index.d.ts;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-26 08:13:27 +02:00
Dmitriy Mozgovoy c05ad48952 Fixed toFormData regression bug (unreleased) with Array-like objects serialization; (#4714)
Added `toURLEncodedForm` helper;
Added automatic payload serialization to `application/x-www-form-urlencoded` to have parity with `multipart/form-data`;
Added test of handling `application/x-www-form-urlencoded` body by express.js;
Updated README.md;
Added missed param in JSDoc;
Fixed hrefs in README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-16 08:30:17 +02:00
Dmitriy Mozgovoy 807918bda2 Added enhanced toFormData implementation with additional options support; (#4704)
Updated default notation for arrays and objects to bracket style;
Added `multer/express.js` tests;
Updated README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-11 19:30:08 +02:00
Landro3 544cf134f3 Interceptor clear (#4248)
* Adding interceptor clearing

* Fixing spacing

* changed clear to empty array

* fixed interceptor clear test

Co-authored-by: Andrew <Andrew@Andrews-MacBook-Pro.local>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-05 21:31:06 +02:00
Afzal Sayed 7e56f8653c Fix grammatical issues in README (#4232)
* Fix grammatical issues in README

* Fix typo in COLLABORATOR_GUIDE.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-05 21:02:32 +02:00
reslear 1430393402 Update README.md (#4207)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 21:12:12 +02:00
Jay e8e4749ebf Updated all browser logos to be correct 2022-05-04 19:27:42 +02:00
Kai b4d87ce6ca Updating HTTP links in README.md to use HTTPS (#4387)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 18:15:37 +02:00
Kumar Shanu 6b1ae0b84a Edited readme with 3 updated browser icons. (#4414)
In the main readme file of axios, the icons for chrome, firefox and safari was not visible, which was giving a bit outdated vibes. I have updated all the three icons with the latest ones from  "https://www.iconfinder.com/icons/23799/firefox_icon" in 48px dimension. I hope now it looks good.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 21:46:08 +02:00
Alexander Shchukin 484443f251 fix url to defaults.js (#4532)
fix url to defaults.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 20:35:59 +02:00
Ted Robertson e9efc69f68 Emphasize the URLSearchParam built-in interface (#4590)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 19:00:38 +02:00
aong a41f129acf Update README.md (#4599)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 18:50:13 +02:00
Dan Mooney 8fb0f2689d Update README.md (#4649)
Fix grammar

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 18:40:15 +02:00
Jay 8699891b8e Fixed merge conflicts 2022-04-01 18:40:12 +02:00
Dmitriy Mozgovoy 6b9b05b907 Improved FormData support; (#4448)
* Fixed isFormData predicate;
Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment through `form-data` package;

* Added the `form-data` package as a dependency for the server build;
Added tests for FormData payload;

* Added FormData automatic serialization section;
Refactored cancellation section;

* Reworked toFormData helper;
Expose toFormData helper as a static method;
Refactored transform request;
Added kindOf, kindOfTest, endsWith, isTypedArray util;
Refactored utils.js to use kindOf for tests;

* Fixed isFormData predicate; (#4413)

Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment using `form-data` package;

(cherry picked from commit 73e3bdb883)

* Added shortcut methods `postForm`, `putForm`, `patchForm` to submit a Form;
Added ability to submit FileList object as a FormData;
Updated README.md;

* Updated README.md;
2022-03-14 20:22:10 +02:00
Rijk van Zanten 8e67551177 Update line on methods, update TS definition to allow strings (#3802)
Fixes #3140

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-08 08:26:07 +02:00
Zoran Kokeza 412d3bd607 Adding support for beforeRedirect config option (#3852)
* Adding support for beforeRedirect config option

* Adding tests for beforeRedirect

* Update README.md

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>

* fix types

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 19:46:08 +02:00
Nicholas Juntilla 3d13b67c56 Fix FormData example (#4391)
You need to have form.getBuffer() in order for the FormData library to submit from node.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 09:45:12 +02:00
Tomás Raiti 45cb5ad716 Updated README example to be coherent with the CommonJS usage (#4418)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 09:35:48 +02:00
CookieMr c5bdbd436d Update follow-redirects dependency due to Vurnerbility
Previous version of follow-redirects dependency is reported
by Snyk to have a vurnerbility.
https://app.snyk.io/test/npm/follow-redirects/1.14.7
2022-02-11 14:58:12 +01:00
Wolfram Kriesing e6aef5a1c4 (Add tests to) document how multiple inceptors work (#3564)
* Add a group for the multiple-interceptors tests.

The current test contains a lot of details that are worth being tested
separately and also made explicit. This is what is coming with the next changes.

* Fix indentation.

* Make explicit that the test only tests the interception of the fulfilled part.

* Indent.

* Make the test just test a tiny bit, as described.

The more explicit the test, the better we can 1) describe what it does
and use that for the docs to make them understandable 2) have a better
explicit description of the API (in case we want to modify it) and 3) have
a regression test when changing.

* Add a test that explicitly shows that the order of interceptors is as they were added.

* Pull out reusable code, to make the tests more explicitly stating the things they care about.

* Write a test showing that the responses are not merged or anything,
only the last one in the chain is returned.

* Make visible that the interceptors are a chain, one receives its predecessor's data.

* Test what happens when the interceptor throws.

* Refactor, add another group of tests and pull helper function there.

The previous change to also catch in the helper function was not needed
for any of the tests above, so remove it and put it in the describe-block
below where it is needed.
Just trying to write the specific code needed, not more.
Not sure about the impact for failing tests, I am glad about input.
But the main intention here is to have minimal code, explicit tests and
not too much generic code which might break itself eventually.

* Documenting that the following reject-interceptor gets called.

* Documenting how the interceptor chain handles caught rejections.

* Document "multiple interceptors".

I just extracted the test descriptions from the new/modified tests.
And I also learned that I should improve the test descriptions, the
tests are just in a GIVEN-WHEN-THEN structure, so I can also use those
terms better. Will do this next.

* Transfer the better readable descriptions as I changed them in the README back into the tests.

After I had updated the README using the test descriptions I realized how
the test descriptions can be improved, so I did this "moving" the learnings
back into the code.

* Be a bit more explicit, it was not clear when reading, imho.

* Add new lines to be kinda consistent with the rest of the file.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:14:52 +02:00
HyperLifelll9 20e8b6bc8c chore(docs): rename Angular to AngularJS (#4114)
* chore(docs): rename Angular to AngularJS

As we all know, Angular and AngularJS are separate, and now we often say Angular refers to Angular2+.

* Update README.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 10:06:11 +02:00
Jay 76f09afc03 Release/v0.22.0 (#4107)
* fix/Avoid package.json import; (#4041)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Feat/export package version constant (#4065)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Export package version constant;

* Fixed cancelToken leakage; Added AbortController support; (#3305)

* Fixed cancelToken leakage;
Added AbortController support;

* Fixed typings;

* Documented `signal` option;

* Added processing of early cancellation using AbortController without sending a request;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Updating CI to run on release branches

* Fixed default transitional config for custom Axios instance; (#4052)

Refactored `/core/mergeConfig`;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Prepping v0.22.0 for release

* Updated date

Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
2021-10-01 08:02:13 +02:00
Jay 4091b075f6 Release/0.21.4 (#4025)
* fix json transform when data is pre-stringified (#4020)

* [Updating] incorrect JSON syntax in README.md

* [Releasing] v0.21.4

Co-authored-by: Guillaume FORTAINE <guillaume+github@fortaine.com>
2021-09-06 17:35:06 +02:00
Fabiel Leon b5a1a67b3c Adding nodejs http.request option: insecureHTTPParser (#2930)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 13:43:49 +02:00
Sam Carlton e10a0270e9 Fix README typo under Request Config (#3825)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-08-13 14:55:00 +02:00
Mo Sattler e091491127 Update README.md (#3936)
Fixing the example JSON of `Request Config`

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-08-13 14:45:46 +02:00
Jay b42fbad57b Removed un-needed bracket
Removed un-needed bracket
2021-08-13 14:36:02 +02:00
Jay 520c8dccde Updating CI status badge (#3953)
Updated CI status badge to show Github workflow status
2021-08-13 14:35:20 +02:00
Jay 3958e9fbc8 Add explanation of cancel token (#3803)
Thanks to @socketpair for testing and checking this.
2021-05-18 09:08:20 +02:00
Johannes Jarbratt 94fc4ea716 Adding isAxiosError typeguard documentation (#3767)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-05-04 20:05:05 +02:00
Dmitriy Mozgovoy 5ad6994da3 JSON improvements: throw if JSON parsing failed; number, boolean can be passed directly as payload for encoding to JSON #2613, #61, #907 (#3688)
* Draft

* Added support for primitive types to be converted to JSON if the request Content-Type is 'application/json';
Added throwing SyntaxError if JSON parsing failed and responseType is json;
Added transitional option object;
Added options validator to assert transitional options;
Added transitional option `silentJSONParsing= true` for backward compatibility;
Updated README.md;
Updated typings;

* Fixed isOlderVersion helper;
Fixed typo;
Added validator.spec.js;

* Added forcedJSONParsing transitional option #2791

* `transformData` is now called in the default configuration context if the function context is not specified (for tests compatibility);

* Added `transitional.clarifyTimeoutError` to throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts;
Added support of onloadend handler if available instead of onreadystatechange;
Added xhr timeout test;
Fixed potential bug of xhr adapter with proper handling timeouts&errors (FakeXMLHTTPRequest failed to handle timeouts);
2021-04-19 18:55:34 +02:00
Jay c0317b7453 Update README.md (#3707) 2021-03-29 16:43:29 +02:00
Sasha Korotkov 62d6256039 issue#2609 | Sasha | predictable axios requests (#2702)
* issue#2609 | Sasha | predictable axios requests

- axios requests are not delayed by pre-emptive promise creation by default
- add options to interceptors api ("synchronous" and "runWhen")
- add documentation and unit tests

* issue#2609 | Sasha | pull request feedback changes

* issue#2609 | Sasha | additional feedback changes

* issue#2609 | Sasha | put back try/catch

* issue#2609 | Sasha | add 2 adapter unit tests

- remove check for requestCancelled

Co-authored-by: ak71845 <alexandre.korotkov@kroger.com>
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-03-01 11:11:35 +02:00
Nisar Hassan Naqvi 535d0c45c1 move the mention of gitpod to the main readme + modify gitpod description. (#2637)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-02-17 08:28:00 +02:00
Ali Clark fe52a611ef Default headers example AUTH_TOKEN comment (#3539)
* Updating the 'Global axios defaults' README to use a safer example

The existing example usage it isn't safe in the general case as it can
lead to auth tokens being leaked to 3rd party endpoints by unexpectedly.

This change instead gives an example using
"axios.defaults.headers.common" to set the User-Agent, which is an
equally helpful use-case to document.

The 'Custom instance defaults' example just below the 'Global axios
defaults' example shows a method to set the 'Authorization' header
specific to a given API. I've also updated the variable in the 'Custom
instance defaults' code to use a semantically more relevant name within
that example.

* Revert the example instance name in response to PR request

* Reintroduce the Authorization example with a disclaimer about its usage

* Update wording nb -> important on usage comment

* Remove User-Agent example due to issues with this on Chrome and Safari

See https://github.com/axios/axios/issues/1231
Credit @chinesedfan for pointing this out
2021-01-12 16:52:42 +02:00