Comparing version 1.4.0 to 0.27.2
1199
CHANGELOG.md
# Changelog | ||
# [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27) | ||
### 0.27.2 (April 27, 2022) | ||
Fixes and Functionality: | ||
- Fixed FormData posting in browser environment by reverting #3785 ([#4640](https://github.com/axios/axios/pull/4640)) | ||
- Enhanced protocol parsing implementation ([#4639](https://github.com/axios/axios/pull/4639)) | ||
- Fixed bundle size | ||
### Bug Fixes | ||
### 0.27.1 (April 26, 2022) | ||
* **formdata:** add `multipart/form-data` content type for FormData payload on custom client environments; ([#5678](https://github.com/axios/axios/issues/5678)) ([bbb61e7](https://github.com/axios/axios/commit/bbb61e70cb1185adfb1cbbb86eaf6652c48d89d1)) | ||
* **package:** export package internals with unsafe path prefix; ([#5677](https://github.com/axios/axios/issues/5677)) ([df38c94](https://github.com/axios/axios/commit/df38c949f26414d88ba29ec1e353c4d4f97eaf09)) | ||
Fixes and Functionality: | ||
- Removed import of url module in browser build due to huge size overhead and builds being broken ([#4594](https://github.com/axios/axios/pull/4594)) | ||
- Bumped follow-redirects to ^1.14.9 ([#4615](https://github.com/axios/axios/pull/4615)) | ||
### 0.27.0 (April 25, 2022) | ||
### Features | ||
Breaking changes: | ||
- New toFormData helper function that allows the implementor to pass an object and allow axios to convert it to FormData ([#3757](https://github.com/axios/axios/pull/3757)) | ||
- Removed functionality that removed the the `Content-Type` request header when passing FormData ([#3785](https://github.com/axios/axios/pull/3785)) | ||
- **(*)** Refactored error handling implementing AxiosError as a constructor, this is a large change to error handling on the whole ([#3645](https://github.com/axios/axios/pull/3645)) | ||
- Separated responsibility for FormData instantiation between `transformRequest` and `toFormData` ([#4470](https://github.com/axios/axios/pull/4470)) | ||
- **(*)** Improved and fixed multiple issues with FormData support ([#4448](https://github.com/axios/axios/pull/4448)) | ||
* **dns:** added support for a custom lookup function; ([#5339](https://github.com/axios/axios/issues/5339)) ([2701911](https://github.com/axios/axios/commit/2701911260a1faa5cc5e1afe437121b330a3b7bb)) | ||
* **types:** export `AxiosHeaderValue` type. ([#5525](https://github.com/axios/axios/issues/5525)) ([726f1c8](https://github.com/axios/axios/commit/726f1c8e00cffa0461a8813a9bdcb8f8b9d762cf)) | ||
QOL and DevX improvements: | ||
- Added a multipart/form-data testing playground allowing contributors to debug changes easily ([#4465](https://github.com/axios/axios/pull/4465)) | ||
Fixes and Functionality: | ||
- Refactored project file structure to avoid circular imports ([#4515](https://github.com/axios/axios/pull/4516)) & ([#4516](https://github.com/axios/axios/pull/4516)) | ||
- Bumped follow-redirects to ^1.14.9 ([#4562](https://github.com/axios/axios/pull/4562)) | ||
### Performance Improvements | ||
Internal and Tests: | ||
- Updated dev dependencies to latest version | ||
* **merge-config:** optimize mergeConfig performance by avoiding duplicate key visits; ([#5679](https://github.com/axios/axios/issues/5679)) ([e6f7053](https://github.com/axios/axios/commit/e6f7053bf1a3e87cf1f9da8677e12e3fe829d68e)) | ||
Documentation: | ||
- Fixing incorrect link in changelog ([#4551](https://github.com/axios/axios/pull/4551)) | ||
### Contributors to this release | ||
Notes: | ||
- **(*)** Please read these pull requests before updating, these changes are very impactful and far reaching. | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+151/-16 (#5684 #5339 #5679 #5678 #5677 )") | ||
- <img src="https://avatars.githubusercontent.com/u/47537704?v=4&s=18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )") | ||
- <img src="https://avatars.githubusercontent.com/u/43876655?v=4&s=18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )") | ||
### 0.26.1 (March 9, 2022) | ||
## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19) | ||
Fixes and Functionality: | ||
- Refactored project file structure to avoid circular imports ([#4220](https://github.com/axios/axios/pull/4220)) | ||
### 0.26.0 (February 13, 2022) | ||
### Bug Fixes | ||
Fixes and Functionality: | ||
- Fixed The timeoutErrorMessage property in config not work with Node.js ([#3581](https://github.com/axios/axios/pull/3581)) | ||
- Added errors to be displayed when the query parsing process itself fails ([#3961](https://github.com/axios/axios/pull/3961)) | ||
- Fix/remove url required ([#4426](https://github.com/axios/axios/pull/4426)) | ||
- Update follow-redirects dependency due to Vulnerability ([#4462](https://github.com/axios/axios/pull/4462)) | ||
- Bump karma from 6.3.11 to 6.3.14 ([#4461](https://github.com/axios/axios/pull/4461)) | ||
- Bump follow-redirects from 1.14.7 to 1.14.8 ([#4473](https://github.com/axios/axios/pull/4473)) | ||
* **types:** added transport to RawAxiosRequestConfig ([#5445](https://github.com/axios/axios/issues/5445)) ([6f360a2](https://github.com/axios/axios/commit/6f360a2531d8d70363fd9becef6a45a323f170e2)) | ||
* **utils:** make isFormData detection logic stricter to avoid unnecessary calling of the `toString` method on the target; ([#5661](https://github.com/axios/axios/issues/5661)) ([aa372f7](https://github.com/axios/axios/commit/aa372f7306295dfd1100c1c2c77ce95c95808e76)) | ||
### 0.25.0 (January 18, 2022) | ||
### Contributors to this release | ||
Breaking changes: | ||
- Fixing maxBodyLength enforcement ([#3786](https://github.com/axios/axios/pull/3786)) | ||
- Don't rely on strict mode behavior for arguments ([#3470](https://github.com/axios/axios/pull/3470)) | ||
- Adding error handling when missing url ([#3791](https://github.com/axios/axios/pull/3791)) | ||
- Update isAbsoluteURL.js removing escaping of non-special characters ([#3809](https://github.com/axios/axios/pull/3809)) | ||
- Use native Array.isArray() in utils.js ([#3836](https://github.com/axios/axios/pull/3836)) | ||
- Adding error handling inside stream end callback ([#3967](https://github.com/axios/axios/pull/3967)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+48/-10 (#5665 #5661 #5663 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+2/-0 (#5445 )") | ||
Fixes and Functionality: | ||
- Added aborted even handler ([#3916](https://github.com/axios/axios/pull/3916)) | ||
- Header types expanded allowing `boolean` and `number` types ([#4144](https://github.com/axios/axios/pull/4144)) | ||
- Fix cancel signature allowing cancel message to be `undefined` ([#3153](https://github.com/axios/axios/pull/3153)) | ||
- Updated type checks to be formulated better ([#3342](https://github.com/axios/axios/pull/3342)) | ||
- Avoid unnecessary buffer allocations ([#3321](https://github.com/axios/axios/pull/3321)) | ||
- Adding a socket handler to keep TCP connection live when processing long living requests ([#3422](https://github.com/axios/axios/pull/3422)) | ||
- Added toFormData helper function ([#3757](https://github.com/axios/axios/pull/3757)) | ||
- Adding responseEncoding prop type in AxiosRequestConfig ([#3918](https://github.com/axios/axios/pull/3918)) | ||
## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05) | ||
Internal and Tests: | ||
- Adding axios-test-instance to ecosystem ([#3496](https://github.com/axios/axios/pull/3496)) | ||
- Optimize the logic of isAxiosError ([#3546](https://github.com/axios/axios/pull/3546)) | ||
- Add tests and documentation to display how multiple inceptors work ([#3564](https://github.com/axios/axios/pull/3564)) | ||
- Updating follow-redirects to version 1.14.7 ([#4379](https://github.com/axios/axios/pull/4379)) | ||
Documentation: | ||
- Fixing changelog to show correct pull request ([#4219](https://github.com/axios/axios/pull/4219)) | ||
- Update upgrade guide for https proxy setting ([#3604](https://github.com/axios/axios/pull/3604)) | ||
### Bug Fixes | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
* **headers:** fixed isValidHeaderName to support full list of allowed characters; ([#5584](https://github.com/axios/axios/issues/5584)) ([e7decef](https://github.com/axios/axios/commit/e7decef6a99f4627e27ed9ea5b00ce8e201c3841)) | ||
* **params:** re-added the ability to set the function as `paramsSerializer` config; ([#5633](https://github.com/axios/axios/issues/5633)) ([a56c866](https://github.com/axios/axios/commit/a56c8661209d5ce5a645a05f294a0e08a6c1f6b3)) | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Rijk van Zanten](https://github.com/rijkvanzanten) | ||
- [Kohta Ito](https://github.com/koh110) | ||
- [Brandon Faulkner](https://github.com/bfaulk96) | ||
- [Stefano Magni](https://github.com/NoriSte) | ||
- [enofan](https://github.com/fanguangyi) | ||
- [Andrey Pechkurov](https://github.com/puzpuzpuz) | ||
- [Doowonee](https://github.com/doowonee) | ||
- [Emil Broman](https://github.com/emilbroman-eqt) | ||
- [Remco Haszing](https://github.com/remcohaszing) | ||
- [Black-Hole](https://github.com/BlackHole1) | ||
- [Wolfram Kriesing](https://github.com/wolframkriesing) | ||
- [Andrew Ovens](https://github.com/repl-andrew-ovens) | ||
- [Paulo Renato](https://github.com/PauloRSF) | ||
- [Ben Carp](https://github.com/carpben) | ||
- [Hirotaka Tagawa](https://github.com/wafuwafu13) | ||
- [ηΌζε°η](https://github.com/lzxb) | ||
- [C. Lewis](https://github.com/ctjlewis) | ||
- [Felipe Carvalho](https://github.com/FCarvalhoVII) | ||
- [Daniel](https://github.com/djs113) | ||
- [Gustavo Sales](https://github.com/gussalesdev) | ||
### Contributors to this release | ||
### 0.24.0 (October 25, 2021) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+28/-10 (#5633 #5584 )") | ||
Breaking changes: | ||
- Revert: change type of AxiosResponse to any, please read lengthy discussion here: ([#4141](https://github.com/axios/axios/issues/4141)) pull request: ([#4186](https://github.com/axios/axios/pull/4186)) | ||
## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Rodry](https://github.com/ImRodry) | ||
- [Remco Haszing](https://github.com/remcohaszing) | ||
- [Isaiah Thomason](https://github.com/ITenthusiasm) | ||
### Bug Fixes | ||
### 0.23.0 (October 12, 2021) | ||
* **blob:** added a check to make sure the Blob class is available in the browser's global scope; ([#5548](https://github.com/axios/axios/issues/5548)) ([3772c8f](https://github.com/axios/axios/commit/3772c8fe74112a56e3e9551f894d899bc3a9443a)) | ||
* **http:** fixed regression bug when handling synchronous errors inside the adapter; ([#5564](https://github.com/axios/axios/issues/5564)) ([a3b246c](https://github.com/axios/axios/commit/a3b246c9de5c3bc4b5a742e15add55b375479451)) | ||
Breaking changes: | ||
- Distinguish request and response data types ([#4116](https://github.com/axios/axios/pull/4116)) | ||
- Change never type to unknown ([#4142](https://github.com/axios/axios/pull/4142)) | ||
- Fixed TransitionalOptions typings ([#4147](https://github.com/axios/axios/pull/4147)) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- Adding globalObject: 'this' to webpack config ([#3176](https://github.com/axios/axios/pull/3176)) | ||
- Adding insecureHTTPParser type to AxiosRequestConfig ([#4066](https://github.com/axios/axios/pull/4066)) | ||
- Fix missing semicolon in typings ([#4115](https://github.com/axios/axios/pull/4115)) | ||
- Fix response headers types ([#4136](https://github.com/axios/axios/pull/4136)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+38/-26 (#5564 )") | ||
- <img src="https://avatars.githubusercontent.com/u/19550000?v=4&s=18" alt="avatar" width="18"/> [lcysgsg](https://github.com/lcysgsg "+4/-0 (#5548 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-0 (#5444 )") | ||
Internal and Tests: | ||
- Improve timeout error when timeout is browser default ([#3209](https://github.com/axios/axios/pull/3209)) | ||
- Fix node version on CI ([#4069](https://github.com/axios/axios/pull/4069)) | ||
- Added testing to TypeScript portion of project ([#4140](https://github.com/axios/axios/pull/4140)) | ||
## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13) | ||
Documentation: | ||
- Rename Angular to AngularJS ([#4114](https://github.com/axios/axios/pull/4114)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Bug Fixes | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Evan-Finkelstein](https://github.com/Evan-Finkelstein) | ||
- [PaweΕ SzymaΕski](https://github.com/Jezorko) | ||
- [Dobes Vandermeer](https://github.com/dobesv) | ||
- [Claas Augner](https://github.com/caugner) | ||
- [Remco Haszing](https://github.com/remcohaszing) | ||
- [Evgeniy](https://github.com/egmen) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
* **formdata:** added a check to make sure the FormData class is available in the browser's global scope; ([#5545](https://github.com/axios/axios/issues/5545)) ([a6dfa72](https://github.com/axios/axios/commit/a6dfa72010db5ad52db8bd13c0f98e537e8fd05d)) | ||
* **formdata:** fixed setting NaN as Content-Length for form payload in some cases; ([#5535](https://github.com/axios/axios/issues/5535)) ([c19f7bf](https://github.com/axios/axios/commit/c19f7bf770f90ae8307f4ea3104f227056912da1)) | ||
* **headers:** fixed the filtering logic of the clear method; ([#5542](https://github.com/axios/axios/issues/5542)) ([ea87ebf](https://github.com/axios/axios/commit/ea87ebfe6d1699af072b9e7cd40faf8f14b0ab93)) | ||
### 0.22.0 (October 01, 2021) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- Caseless header comparing in HTTP adapter ([#2880](https://github.com/axios/axios/pull/2880)) | ||
- Avoid package.json import fixing issues and warnings related to this ([#4041](https://github.com/axios/axios/pull/4041)), ([#4065](https://github.com/axios/axios/pull/4065)) | ||
- Fixed cancelToken leakage and added AbortController support ([#3305](https://github.com/axios/axios/pull/3305)) | ||
- Updating CI to run on release branches | ||
- Bump follow redirects version | ||
- Fixed default transitional config for custom Axios instance; ([#4052](https://github.com/axios/axios/pull/4052)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+11/-7 (#5545 #5535 #5542 )") | ||
- <img src="https://avatars.githubusercontent.com/u/19842213?v=4&s=18" alt="avatar" width="18"/> [ιθ₯ζ«](https://github.com/ruofee "+2/-2 (#5467 )") | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03) | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Matt R. Wilson](https://github.com/mastermatt) | ||
- [Xianming Zhong](https://github.com/chinesedfan) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
### 0.21.4 (September 6, 2021) | ||
### Bug Fixes | ||
Fixes and Functionality: | ||
- Fixing JSON transform when data is stringified. Providing backward compatibility and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020)) | ||
* **http:** treat http://localhost as base URL for relative paths to avoid `ERR_INVALID_URL` error; ([#5528](https://github.com/axios/axios/issues/5528)) ([128d56f](https://github.com/axios/axios/commit/128d56f4a0fb8f5f2ed6e0dd80bc9225fee9538c)) | ||
* **http:** use explicit import instead of TextEncoder global; ([#5530](https://github.com/axios/axios/issues/5530)) ([6b3c305](https://github.com/axios/axios/commit/6b3c305fc40c56428e0afabedc6f4d29c2830f6f)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Contributors to this release | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Guillaume Fortaine](https://github.com/gfortaine) | ||
- [Yusuke Kawasaki](https://github.com/kawanet) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+2/-1 (#5530 #5528 )") | ||
### 0.21.3 (September 4, 2021) | ||
## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01) | ||
Fixes and Functionality: | ||
- Fixing response interceptor not being called when request interceptor is attached ([#4013](https://github.com/axios/axios/pull/4013)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Bug Fixes | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Julian Hollmann](https://github.com/nerdbeere) | ||
* **formdata:** add hotfix to use the asynchronous API to compute the content-length header value; ([#5521](https://github.com/axios/axios/issues/5521)) ([96d336f](https://github.com/axios/axios/commit/96d336f527619f21da012fe1f117eeb53e5a2120)) | ||
* **serializer:** fixed serialization of array-like objects; ([#5518](https://github.com/axios/axios/issues/5518)) ([08104c0](https://github.com/axios/axios/commit/08104c028c0f9353897b1b6691d74c440fd0c32d)) | ||
### 0.21.2 (September 4, 2021) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )") | ||
- Updating axios requests to be delayed by pre-emptive promise creation ([#2702](https://github.com/axios/axios/pull/2702)) | ||
- Adding "synchronous" and "runWhen" options to interceptors api ([#2702](https://github.com/axios/axios/pull/2702)) | ||
- Updating of transformResponse ([#3377](https://github.com/axios/axios/pull/3377)) | ||
- Adding ability to omit User-Agent header ([#3703](https://github.com/axios/axios/pull/3703)) | ||
- Adding multiple JSON improvements ([#3688](https://github.com/axios/axios/pull/3688), [#3763](https://github.com/axios/axios/pull/3763)) | ||
- Fixing quadratic runtime and extra memory usage when setting a maxContentLength ([#3738](https://github.com/axios/axios/pull/3738)) | ||
- Adding parseInt to config.timeout ([#3781](https://github.com/axios/axios/pull/3781)) | ||
- Adding custom return type support to interceptor ([#3783](https://github.com/axios/axios/pull/3783)) | ||
- Adding security fix for ReDoS vulnerability ([#3980](https://github.com/axios/axios/pull/3980)) | ||
# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31) | ||
Internal and Tests: | ||
- Updating build dev dependencies ([#3401](https://github.com/axios/axios/pull/3401)) | ||
- Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538)) | ||
- Updating follow redirect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771)) | ||
- 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)) | ||
- Updating content-type header for application/json to not contain charset field, according do RFC 8259 ([#2154](https://github.com/axios/axios/pull/2154)) | ||
- Fixing tests by bumping karma-sauce-launcher version ([#3813](https://github.com/axios/axios/pull/3813)) | ||
- Changing testing process from Travis CI to GitHub Actions ([#3938](https://github.com/axios/axios/pull/3938)) | ||
### Bug Fixes | ||
Documentation: | ||
* **headers:** fixed & optimized clear method; ([#5507](https://github.com/axios/axios/issues/5507)) ([9915635](https://github.com/axios/axios/commit/9915635c69d0ab70daca5738488421f67ca60959)) | ||
* **http:** add zlib headers if missing ([#5497](https://github.com/axios/axios/issues/5497)) ([65e8d1e](https://github.com/axios/axios/commit/65e8d1e28ce829f47a837e45129730e541950d3c)) | ||
- Updating documentation around the use of `AUTH_TOKEN` with multiple domain endpoints ([#3539](https://github.com/axios/axios/pull/3539)) | ||
- Remove duplication of item in changelog ([#3523](https://github.com/axios/axios/pull/3523)) | ||
- Fixing grammatical errors ([#2642](https://github.com/axios/axios/pull/2642)) | ||
- Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567)) | ||
- Moving gitpod mention ([#2637](https://github.com/axios/axios/pull/2637)) | ||
- Adding new axios documentation website link ([#3681](https://github.com/axios/axios/pull/3681), [#3707](https://github.com/axios/axios/pull/3707)) | ||
- Updating documentation around dispatching requests ([#3772](https://github.com/axios/axios/pull/3772)) | ||
- Adding documentation for the type guard isAxiosError ([#3767](https://github.com/axios/axios/pull/3767)) | ||
- Adding explanation of cancel token ([#3803](https://github.com/axios/axios/pull/3803)) | ||
- Updating CI status badge ([#3953](https://github.com/axios/axios/pull/3953)) | ||
- Fixing errors with JSON documentation ([#3936](https://github.com/axios/axios/pull/3936)) | ||
- Fixing README typo under Request Config ([#3825](https://github.com/axios/axios/pull/3825)) | ||
- Adding axios-multi-api to the ecosystem file ([#3817](https://github.com/axios/axios/pull/3817)) | ||
- Adding SECURITY.md to properly disclose security vulnerabilities ([#3981](https://github.com/axios/axios/pull/3981)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Features | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Sasha Korotkov](https://github.com/SashaKoro) | ||
- [Daniel Lopretto](https://github.com/timemachine3030) | ||
- [Mike Bishop](https://github.com/MikeBishop) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Mark](https://github.com/bimbiltu) | ||
- [Philipe Gouveia PaixΓ£o](https://github.com/piiih) | ||
- [hippo](https://github.com/hippo2cat) | ||
- [ready-research](https://github.com/ready-research) | ||
- [Xianming Zhong](https://github.com/chinesedfan) | ||
- [Christopher Chrapka](https://github.com/OJezu) | ||
- [Brian Anglin](https://github.com/anglinb) | ||
- [Kohta Ito](https://github.com/koh110) | ||
- [Ali Clark](https://github.com/aliclark) | ||
- [caikan](https://github.com/caikan) | ||
- [Elina Gorshkova](https://github.com/elinagorshkova) | ||
- [Ryota Ikezawa](https://github.com/paveg) | ||
- [Nisar Hassan Naqvi](https://github.com/nisarhassan12) | ||
- [Jake](https://github.com/codemaster138) | ||
- [TagawaHirotaka](https://github.com/wafuwafu13) | ||
- [Johannes Jarbratt](https://github.com/johachi) | ||
- [Mo Sattler](https://github.com/MoSattler) | ||
- [Sam Carlton](https://github.com/ThatGuySam) | ||
- [Matt CzapliΕski](https://github.com/MattCCC) | ||
- [Ziding Zhang](https://github.com/zidingz) | ||
* **fomdata:** added support for spec-compliant FormData & Blob types; ([#5316](https://github.com/axios/axios/issues/5316)) ([6ac574e](https://github.com/axios/axios/commit/6ac574e00a06731288347acea1e8246091196953)) | ||
### 0.21.1 (December 21, 2020) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )") | ||
- <img src="https://avatars.githubusercontent.com/u/35015993?v=4&s=18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )") | ||
- Hotfix: Prevent SSRF ([#3410](https://github.com/axios/axios/pull/3410)) | ||
- Protocol not parsed when setting proxy config from env vars ([#3070](https://github.com/axios/axios/pull/3070)) | ||
- Updating axios in types to be lower case ([#2797](https://github.com/axios/axios/pull/2797)) | ||
- Adding a type guard for `AxiosError` ([#2949](https://github.com/axios/axios/pull/2949)) | ||
## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28) | ||
Internal and Tests: | ||
- Remove the skipping of the `socket` http test ([#3364](https://github.com/axios/axios/pull/3364)) | ||
- Use different socket for Win32 test ([#3375](https://github.com/axios/axios/pull/3375)) | ||
### Bug Fixes | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
* **headers:** added missed Authorization accessor; ([#5502](https://github.com/axios/axios/issues/5502)) ([342c0ba](https://github.com/axios/axios/commit/342c0ba9a16ea50f5ed7d2366c5c1a2c877e3f26)) | ||
* **types:** fixed `CommonRequestHeadersList` & `CommonResponseHeadersList` types to be private in commonJS; ([#5503](https://github.com/axios/axios/issues/5503)) ([5a3d0a3](https://github.com/axios/axios/commit/5a3d0a3234d77361a1bc7cedee2da1e11df08e2c)) | ||
- Daniel Lopretto <timemachine3030@users.noreply.github.com> | ||
- Jason Kwok <JasonHK@users.noreply.github.com> | ||
- Jay <jasonsaayman@gmail.com> | ||
- Jonathan Foster <jonathan@jonathanfoster.io> | ||
- Remco Haszing <remcohaszing@gmail.com> | ||
- Xianming Zhong <chinesedfan@qq.com> | ||
### Contributors to this release | ||
### 0.21.0 (October 23, 2020) | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )") | ||
Fixes and Functionality: | ||
## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26) | ||
- Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287)) | ||
- Fixing node types ([#3237](https://github.com/axios/axios/pull/3237)) | ||
- Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282)) | ||
- Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289)) | ||
- 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)) | ||
Internal and Tests: | ||
### Bug Fixes | ||
- Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361)) | ||
* **types:** fixed AxiosHeaders to handle spread syntax by making all methods non-enumerable; ([#5499](https://github.com/axios/axios/issues/5499)) ([580f1e8](https://github.com/axios/axios/commit/580f1e8033a61baa38149d59fd16019de3932c22)) | ||
Documentation: | ||
### Contributors to this release | ||
- Fixing simple typo, existent -> existent ([#3252](https://github.com/axios/axios/pull/3252)) | ||
- Fixing typos ([#3309](https://github.com/axios/axios/pull/3309)) | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+82/-54 (#5499 )") | ||
- ![avatar](https://avatars.githubusercontent.com/u/20516159?v=4&s=16) [Elliot Ford](https://github.com/EFord36 "+1/-1 (#5462 )") | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22) | ||
- Allan Cruz <57270969+Allanbcruz@users.noreply.github.com> | ||
- George Cheng <Gerhut@GMail.com> | ||
- Jay <jasonsaayman@gmail.com> | ||
- Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com> | ||
- Remco Haszing <remcohaszing@gmail.com> | ||
- Taemin Shin <cprayer13@gmail.com> | ||
- Tim Gates <tim.gates@iress.com> | ||
- Xianming Zhong <chinesedfan@qq.com> | ||
### 0.20.0 (August 20, 2020) | ||
### Bug Fixes | ||
Release of 0.20.0-pre as a full release with no other changes. | ||
* **types:** renamed `RawAxiosRequestConfig` back to `AxiosRequestConfig`; ([#5486](https://github.com/axios/axios/issues/5486)) ([2a71f49](https://github.com/axios/axios/commit/2a71f49bc6c68495fa419003a3107ed8bd703ad0)) | ||
* **types:** fix `AxiosRequestConfig` generic; ([#5478](https://github.com/axios/axios/issues/5478)) ([9bce81b](https://github.com/axios/axios/commit/186ea062da8b7d578ae78b1a5c220986b9bce81b)) | ||
### 0.20.0-pre (July 15, 2020) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+242/-108 (#5486 #5482 )") | ||
- ![avatar](https://avatars.githubusercontent.com/u/9430821?v=4&s=16) [Daniel Hillmann](https://github.com/hilleer "+1/-1 (#5478 )") | ||
- Fixing response with utf-8 BOM can not parse to json ([#2419](https://github.com/axios/axios/pull/2419)) | ||
- fix: remove byte order marker (UTF-8 BOM) when transform response | ||
- fix: remove BOM only utf-8 | ||
- test: utf-8 BOM | ||
- fix: incorrect param name | ||
- Refactor mergeConfig without utils.deepMerge ([#2844](https://github.com/axios/axios/pull/2844)) | ||
- Adding failing test | ||
- Fixing #2587 default custom config persisting | ||
- Adding Concat keys and filter duplicates | ||
- Fixed value from CPE | ||
- update for review feedbacks | ||
- no deepMerge | ||
- only merge between plain objects | ||
- fix rename | ||
- always merge config by mergeConfig | ||
- extract function mergeDeepProperties | ||
- refactor mergeConfig with all keys, and add special logic for validateStatus | ||
- add test for resetting headers | ||
- add lots of tests and fix a bug | ||
- should not inherit `data` | ||
- use simple toString | ||
- Fixing overwrite Blob/File type as Content-Type in browser. ([#1773](https://github.com/axios/axios/pull/1773)) | ||
- Fixing an issue that type 'null' is not assignable to validateStatus ([#2773](https://github.com/axios/axios/pull/2773)) | ||
- Fixing special char encoding ([#1671](https://github.com/axios/axios/pull/1671)) | ||
- removing @ character from replacement list since it is a reserved character | ||
- Updating buildURL test to not include the @ character | ||
- Removing console logs | ||
- Fixing password encoding with special characters in basic authentication ([#1492](https://github.com/axios/axios/pull/1492)) | ||
- Fixing password encoding with special characters in basic authentication | ||
- Adding test to check if password with non-Latin1 characters pass | ||
- Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487)) | ||
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. | ||
- Fixing Cookie Helper with Async Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107)) | ||
- Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851)) | ||
- Fix 'progressEvent' type | ||
- Update axios.ts | ||
- Fixing getting local files (file://) failed ([#2470](https://github.com/axios/axios/pull/2470)) | ||
- fix issue #2416, #2396 | ||
- fix Eslint warn | ||
- Modify judgment conditions | ||
- add unit test | ||
- update unit test | ||
- update unit test | ||
- Allow PURGE method in typings ([#2191](https://github.com/axios/axios/pull/2191)) | ||
- Adding option to disable automatic decompression ([#2661](https://github.com/axios/axios/pull/2661)) | ||
- Adding ability to disable auto decompression | ||
- Updating decompress documentation in README | ||
- Fixing test\unit\adapters\http.js lint errors | ||
- Adding test for disabling auto decompression | ||
- Removing changes that fixed lint errors in tests | ||
- Removing formatting change to unit test | ||
- Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781)) | ||
- Add independent option to set the maximum size of the request body | ||
- Remove maxBodyLength check | ||
- Update README | ||
- Assert for error code and message | ||
- Adding responseEncoding to mergeConfig ([#1745](https://github.com/axios/axios/pull/1745)) | ||
- Compatible with follow-redirect aborts the request ([#2689](https://github.com/axios/axios/pull/2689)) | ||
- Compatible with follow-redirect aborts the request | ||
- Use the error code | ||
- Fix merging of params ([#2656](https://github.com/axios/axios/pull/2656)) | ||
- Name function to avoid ESLint func-names warning | ||
- Switch params config to merge list and update tests | ||
- Restore testing of both false and null | ||
- Restore test cases for keys without defaults | ||
- Include test for non-object values that aren't false-y. | ||
- Revert `finally` as `then` ([#2683](https://github.com/axios/axios/pull/2683)) | ||
## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10) | ||
Internal and Tests: | ||
- Fix stale bot config ([#3049](https://github.com/axios/axios/pull/3049)) | ||
- fix stale bot config | ||
- fix multiple lines | ||
- Add days and change name to work ([#3035](https://github.com/axios/axios/pull/3035)) | ||
- Update close-issues.yml ([#3031](https://github.com/axios/axios/pull/3031)) | ||
- Update close-issues.yml | ||
Update close message to read better π | ||
- Fix use of quotations | ||
Use single quotes as per other .yml files | ||
- Remove user name form message | ||
- Add GitHub actions to close stale issues/prs ([#3029](https://github.com/axios/axios/pull/3029)) | ||
- prepare stale actions | ||
- update messages | ||
- Add exempt labels and lighten up comments | ||
- Add GitHub actions to close invalid issues ([#3022](https://github.com/axios/axios/pull/3022)) | ||
- add close actions | ||
- fix with checkout | ||
- update issue templates | ||
- add reminder | ||
- update close message | ||
- Add test with Node.js 12 ([#2860](https://github.com/axios/axios/pull/2860)) | ||
- test with Node.js 12 | ||
- test with latest | ||
- Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210)) | ||
- Adding console log on sandbox server startup | ||
- Update server.js | ||
Add server error handling | ||
- Update server.js | ||
Better error message, remove retry. | ||
- Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996)) | ||
Update tests. | ||
- Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695)) | ||
- Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601)) | ||
- Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666)) | ||
- Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748)) | ||
- chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443)) | ||
### Bug Fixes | ||
Documentation: | ||
* **types:** fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; ([#5420](https://github.com/axios/axios/issues/5420)) ([0811963](https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc)) | ||
- Adding support for URLSearchParams in node ([#1900](https://github.com/axios/axios/pull/1900)) | ||
- Adding support for URLSearchParams in node | ||
- Remove un-needed code | ||
- Update utils.js | ||
- Make changes as suggested | ||
- Adding table of content (preview) ([#3050](https://github.com/axios/axios/pull/3050)) | ||
- add toc (preview) | ||
- remove toc in toc | ||
Signed-off-by: Moni <usmoni@gmail.com> | ||
- fix sublinks | ||
- fix indentation | ||
- remove redundant table links | ||
- update caps and indent | ||
- remove axios | ||
- Replace 'blacklist' with 'blocklist' ([#3006](https://github.com/axios/axios/pull/3006)) | ||
- docs(): Detailed config options environment. ([#2088](https://github.com/axios/axios/pull/2088)) | ||
- docs(): Detailed config options environment. | ||
- Update README.md | ||
- Include axios-data-unpacker in ECOSYSTEM.md ([#2080](https://github.com/axios/axios/pull/2080)) | ||
- Allow opening examples in Gitpod ([#1958](https://github.com/axios/axios/pull/1958)) | ||
- Remove axios.all() and axios.spread() from Readme.md ([#2727](https://github.com/axios/axios/pull/2727)) | ||
- remove axios.all(), axios.spread() | ||
- replace example | ||
- axios.all() -> Promise.all() | ||
- axios.spread(function (acct, perms)) -> function (acct, perms) | ||
- add deprecated mark | ||
- Update README.md ([#2887](https://github.com/axios/axios/pull/2887)) | ||
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. | ||
- Include swagger-taxos-codegen in ECOSYSTEM.md ([#2162](https://github.com/axios/axios/pull/2162)) | ||
- Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878)) | ||
This badge will show the version on CDNJS! | ||
- Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928)) | ||
- 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. | ||
- Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912)) | ||
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" | ||
- Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805)) | ||
Closes #2049 | ||
- Fixing CHANGELOG.md issue link ([#2784](https://github.com/axios/axios/pull/2784)) | ||
- Include axios-hooks in ECOSYSTEM.md ([#2003](https://github.com/axios/axios/pull/2003)) | ||
- Added Response header access instructions ([#1901](https://github.com/axios/axios/pull/1901)) | ||
- Added Response header access instructions | ||
- Added note about using bracket notation | ||
- Add `onUploadProgress` and `onDownloadProgress` are browser only ([#2763](https://github.com/axios/axios/pull/2763)) | ||
Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README. | ||
- Update ' sign to ` in proxy spec ([#2778](https://github.com/axios/axios/pull/2778)) | ||
- Adding jsDelivr link in README ([#1110](https://github.com/axios/axios/pull/1110)) | ||
- Adding jsDelivr link | ||
- Add SRI | ||
- Remove SRI | ||
### Contributors to this release | ||
Huge thanks to everyone who contributed to this release via code (authors listed | ||
below) or via reviews and triaging on GitHub: | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+938/-442 (#5456 #5455 #5453 #5451 #5449 #5447 #5446 #5443 #5442 #5439 #5420 )") | ||
- Alan Wang <wp_scut@163.com> | ||
- Alexandru Ungureanu <khakcarot@gmail.com> | ||
- Anubhav Srivastava <anubhav.srivastava00@gmail.com> | ||
- Benny Neugebauer <bn@bennyn.de> | ||
- Cr <631807682@qq.com> | ||
- David <cygnidavid@gmail.com> | ||
- David Ko <david.ko@pvtmethod.com> | ||
- David Tanner <david.tanner@lifeomic.com> | ||
- Emily Morehouse <emilyemorehouse@gmail.com> | ||
- Felipe Martins <felipewmartins@gmail.com> | ||
- Fonger <5862369+Fonger@users.noreply.github.com> | ||
- Frostack <soulburn007@gmail.com> | ||
- George Cheng <Gerhut@GMail.com> | ||
- grumblerchester <grumblerchester@users.noreply.github.com> | ||
- Gustavo LΓ³pez <gualopezb@gmail.com> | ||
- hexaez <45806662+hexaez@users.noreply.github.com> | ||
- huangzuizui <huangzuizui@gmail.com> | ||
- Ian Wijma <ian@wij.ma> | ||
- Jay <jasonsaayman@gmail.com> | ||
- jeffjing <zgayjjf@qq.com> | ||
- jennynju <46782518+jennynju@users.noreply.github.com> | ||
- Jimmy Liao <52391190+jimmy-liao-gogoro@users.noreply.github.com> | ||
- Jonathan Sharpe <j.r.sharpe@gmail.com> | ||
- JounQin <admin@1stg.me> | ||
- Justin Beckwith <justin.beckwith@gmail.com> | ||
- Kamil PosiadaΕa <3dcreator.pl@gmail.com> | ||
- Lukas Drgon <lukas.drgon@gmail.com> | ||
- marcinx <mail@marcinx.com> | ||
- Martti Laine <martti@codeclown.net> | ||
- MichaΕ Zarach <michal.m.zarach@gmail.com> | ||
- Moni <usmoni@gmail.com> | ||
- Motonori Iwata <121048+iwata@users.noreply.github.com> | ||
- Nikita Galkin <nikita@galk.in> | ||
- Petr Mares <petr@mares.tw> | ||
- Philippe Recto <precto1285@gmal.com> | ||
- Remco Haszing <remcohaszing@gmail.com> | ||
- rockcs1992 <chengshi1219@gmail.com> | ||
- Ryan Bown <rbown@niftee.com.au> | ||
- Samina Fu <sufuf3@gmail.com> | ||
- Simone Busoli <simone.busoli@gmail.com> | ||
- Spencer von der Ohe <s.vonderohe40@gmail.com> | ||
- Sven Efftinge <sven.efftinge@typefox.io> | ||
- Taegyeoung Oh <otk1090@naver.com> | ||
- Taemin Shin <cprayer13@gmail.com> | ||
- Thibault Ehrhart <1208424+ehrhart@users.noreply.github.com> | ||
- Xianming Zhong <chinesedfan@qq.com> | ||
- Yasu Flores <carlosyasu91@gmail.com> | ||
- Zac Delventhal <delventhalz@gmail.com> | ||
## [1.2.2] - 2022-12-29 | ||
### 0.19.2 (Jan 20, 2020) | ||
### Fixed | ||
- fix(ci): fix release script inputs [#5392](https://github.com/axios/axios/pull/5392) | ||
- fix(ci): prerelease scipts [#5377](https://github.com/axios/axios/pull/5377) | ||
- fix(ci): release scripts [#5376](https://github.com/axios/axios/pull/5376) | ||
- fix(ci): typescript tests [#5375](https://github.com/axios/axios/pull/5375) | ||
- fix: Brotli decompression [#5353](https://github.com/axios/axios/pull/5353) | ||
- fix: add missing HttpStatusCode [#5345](https://github.com/axios/axios/pull/5345) | ||
- Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion) | ||
### Chores | ||
- chore(ci): set conventional-changelog header config [#5406](https://github.com/axios/axios/pull/5406) | ||
- chore(ci): fix automatic contributors resolving [#5403](https://github.com/axios/axios/pull/5403) | ||
- chore(ci): improved logging for the contributors list generator [#5398](https://github.com/axios/axios/pull/5398) | ||
- chore(ci): fix release action [#5397](https://github.com/axios/axios/pull/5397) | ||
- chore(ci): fix version bump script by adding bump argument for target version [#5393](https://github.com/axios/axios/pull/5393) | ||
- chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 [#5342](https://github.com/axios/axios/pull/5342) | ||
- chore(ci): GitHub Actions Release script [#5384](https://github.com/axios/axios/pull/5384) | ||
- chore(ci): release scripts [#5364](https://github.com/axios/axios/pull/5364) | ||
### 0.19.1 (Jan 7, 2020) | ||
### Contributors to this release | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- ![avatar](https://avatars.githubusercontent.com/u/1652293?v=4&s=16) [Winnie](https://github.com/winniehell) | ||
Fixes and Functionality: | ||
## [1.2.1] - 2022-12-05 | ||
- Fixing invalid agent issue ([#1904](https://github.com/axios/axios/pull/1904)) | ||
- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582)) | ||
- Delete useless default to hash ([#2458](https://github.com/axios/axios/pull/2458)) | ||
- Fix HTTP/HTTPs agents passing to follow-redirect ([#1904](https://github.com/axios/axios/pull/1904)) | ||
- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582)) | ||
- Fix CI build failure ([#2570](https://github.com/axios/axios/pull/2570)) | ||
- Remove dependency on is-buffer from package.json ([#1816](https://github.com/axios/axios/pull/1816)) | ||
- Adding options typings ([#2341](https://github.com/axios/axios/pull/2341)) | ||
- Adding Typescript HTTP method definition for LINK and UNLINK. ([#2444](https://github.com/axios/axios/pull/2444)) | ||
- Update dist with newest changes, fixes Custom Attributes issue | ||
- Change syntax to see if build passes ([#2488](https://github.com/axios/axios/pull/2488)) | ||
- Update Webpack + deps, remove now unnecessary polyfills ([#2410](https://github.com/axios/axios/pull/2410)) | ||
- Fix to prevent XSS, throw an error when the URL contains a JS script ([#2464](https://github.com/axios/axios/pull/2464)) | ||
- Add custom timeout error copy in config ([#2275](https://github.com/axios/axios/pull/2275)) | ||
- Add error toJSON example ([#2466](https://github.com/axios/axios/pull/2466)) | ||
- Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip⦠([#2451](https://github.com/axios/axios/pull/2451)) | ||
- Fixing subdomain handling on no_proxy ([#2442](https://github.com/axios/axios/pull/2442)) | ||
- Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426)) and ([#2547](https://github.com/axios/axios/pull/2547)) | ||
- Add toJSON property to AxiosError type ([#2427](https://github.com/axios/axios/pull/2427)) | ||
- Fixing socket hang up error on node side for slow response. ([#1752](https://github.com/axios/axios/pull/1752)) | ||
- Alternative syntax to send data into the body ([#2317](https://github.com/axios/axios/pull/2317)) | ||
- Fixing custom config options ([#2207](https://github.com/axios/axios/pull/2207)) | ||
- Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383)) | ||
- Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290)) | ||
- 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)) | ||
### Changed | ||
- feat(exports): export mergeConfig [#5151](https://github.com/axios/axios/pull/5151) | ||
Internal: | ||
### Fixed | ||
- fix(CancelledError): include config [#4922](https://github.com/axios/axios/pull/4922) | ||
- fix(general): removing multiple/trailing/leading whitespace [#5022](https://github.com/axios/axios/pull/5022) | ||
- fix(headers): decompression for responses without Content-Length header [#5306](https://github.com/axios/axios/pull/5306) | ||
- fix(webWorker): exception to sending form data in web worker [#5139](https://github.com/axios/axios/pull/5139) | ||
- Revert "Update Webpack + deps, remove now unnecessary polyfills" ([#2479](https://github.com/axios/axios/pull/2479)) | ||
- Order of if/else blocks is causing unit tests mocking XHR. ([#2201](https://github.com/axios/axios/pull/2201)) | ||
- Add license badge ([#2446](https://github.com/axios/axios/pull/2446)) | ||
- Fix travis CI build [#2386](https://github.com/axios/axios/pull/2386) | ||
- Fix cancellation error on build master. #2290 #2207 ([#2407](https://github.com/axios/axios/pull/2407)) | ||
### Refactors | ||
- refactor(types): AxiosProgressEvent.event type to any [#5308](https://github.com/axios/axios/pull/5308) | ||
- refactor(types): add missing types for static AxiosError.from method [#4956](https://github.com/axios/axios/pull/4956) | ||
Documentation: | ||
### Chores | ||
- chore(docs): remove README link to non-existent upgrade guide [#5307](https://github.com/axios/axios/pull/5307) | ||
- chore(docs): typo in issue template name [#5159](https://github.com/axios/axios/pull/5159) | ||
- Fixing typo in CHANGELOG.md: s/Functionallity/Functionality ([#2639](https://github.com/axios/axios/pull/2639)) | ||
- Fix badge, use master branch ([#2538](https://github.com/axios/axios/pull/2538)) | ||
- Fix typo in changelog [#2193](https://github.com/axios/axios/pull/2193) | ||
- Document fix ([#2514](https://github.com/axios/axios/pull/2514)) | ||
- Update docs with no_proxy change, issue #2484 ([#2513](https://github.com/axios/axios/pull/2513)) | ||
- Fixing missing words in docs template ([#2259](https://github.com/axios/axios/pull/2259)) | ||
- πFix request finally documentation in README ([#2189](https://github.com/axios/axios/pull/2189)) | ||
- updating spelling and adding link to docs ([#2212](https://github.com/axios/axios/pull/2212)) | ||
- docs: minor tweak ([#2404](https://github.com/axios/axios/pull/2404)) | ||
- Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399)) | ||
- Update README.md ([#2504](https://github.com/axios/axios/pull/2504)) | ||
- Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432)) | ||
- updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256)) | ||
- Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271)) | ||
- Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198)) | ||
### Contributors to this release | ||
### 0.19.0 (May 30, 2019) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Zachary Lysobey](https://github.com/zachlysobey) | ||
- [Kevin Ennis](https://github.com/kevincennis) | ||
- [Philipp Loose](https://github.com/phloose) | ||
- [secondl1ght](https://github.com/secondl1ght) | ||
- [wenzheng](https://github.com/0x30) | ||
- [Ivan Barsukov](https://github.com/ovarn) | ||
- [Arthur Fiorette](https://github.com/arthurfiorette) | ||
Fixes and Functionality: | ||
## [1.2.0] - 2022-11-10 | ||
- Added support for no_proxy env variable ([#1693](https://github.com/axios/axios/pull/1693/files)) - Chance Dickson | ||
- Unzip response body only for statuses != 204 ([#1129](https://github.com/axios/axios/pull/1129)) - drawski | ||
- Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issues/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev | ||
- Makes Axios error generic to use AxiosResponse ([#1738](https://github.com/axios/axios/pull/1738)) - Suman Lama | ||
- Fixing Mocha tests by locking follow-redirects version to 1.5.10 ([#1993](https://github.com/axios/axios/pull/1993)) - grumblerchester | ||
- Allow uppercase methods in typings. ([#1781](https://github.com/axios/axios/pull/1781)) - Ken Powers | ||
- Fixing building url with hash mark ([#1771](https://github.com/axios/axios/pull/1771)) - Anatoly Ryabov | ||
- 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 `#` | ||
- Preserve HTTP method when following redirect ([#1758](https://github.com/axios/axios/pull/1758)) - Rikki Gibson | ||
- Add `getUri` signature to TypeScript definition. ([#1736](https://github.com/axios/axios/pull/1736)) - Alexander Trauzzi | ||
- Adding isAxiosError flag to errors thrown by axios ([#1419](https://github.com/axios/axios/pull/1419)) - Ayush Gupta | ||
### Changed | ||
Internal: | ||
- changed: refactored module exports [#5162](https://github.com/axios/axios/pull/5162) | ||
- change: re-added support for loading Axios with require('axios').default [#5225](https://github.com/axios/axios/pull/5225) | ||
- Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel | ||
- Fix failing SauceLabs tests by updating configuration - Emily Morehouse | ||
- Add issue templates - Emily Morehouse | ||
### Fixed | ||
Documentation: | ||
- fix: improve AxiosHeaders class [#5224](https://github.com/axios/axios/pull/5224) | ||
- fix: TypeScript type definitions for commonjs [#5196](https://github.com/axios/axios/pull/5196) | ||
- fix: type definition of use method on AxiosInterceptorManager to match the the README [#5071](https://github.com/axios/axios/pull/5071) | ||
- fix: __dirname is not defined in the sandbox [#5269](https://github.com/axios/axios/pull/5269) | ||
- fix: AxiosError.toJSON method to avoid circular references [#5247](https://github.com/axios/axios/pull/5247) | ||
- fix: Z_BUF_ERROR when content-encoding is set but the response body is empty [#5250](https://github.com/axios/axios/pull/5250) | ||
- Consistent coding style in README ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez | ||
- Add information about auth parameter to README ([#2166](https://github.com/axios/axios/pull/2166)) - xlaguna | ||
- 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 | ||
- Update ECOSYSTEM.md - Add Axios Endpoints ([#2176](https://github.com/axios/axios/pull/2176)) - Renan | ||
- Add r2curl in ECOSYSTEM ([#2141](https://github.com/axios/axios/pull/2141)) - μ μ©μ° / CX | ||
- Update README.md - Add instructions for installing with yarn ([#2036](https://github.com/axios/axios/pull/2036)) - Victor Hermes | ||
- Fixing spacing for README.md ([#2066](https://github.com/axios/axios/pull/2066)) - Josh McCarty | ||
- Update README.md. - Change `.then` to `.finally` in example code ([#2090](https://github.com/axios/axios/pull/2090)) - Omar Cai | ||
- Clarify what values responseType can have in Node ([#2121](https://github.com/axios/axios/pull/2121)) - Tyler Breisacher | ||
- docs(ECOSYSTEM): add axios-api-versioning ([#2020](https://github.com/axios/axios/pull/2020)) - Weffe | ||
- 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 | ||
- Update README.md. - Add Querystring library note ([#1896](https://github.com/axios/axios/pull/1896)) - Dmitriy Eroshenko | ||
- Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan | ||
- Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer | ||
### Refactors | ||
- refactor: allowing adapters to be loaded by name [#5277](https://github.com/axios/axios/pull/5277) | ||
### 0.19.0-beta.1 (Aug 9, 2018) | ||
### Chores | ||
**NOTE:** This is a beta version of this release. There may be functionality that is broken in | ||
certain browsers, though we suspect that builds are hanging and not erroring. See | ||
https://saucelabs.com/u/axios for the most up-to-date information. | ||
- chore: force CI restart [#5243](https://github.com/axios/axios/pull/5243) | ||
- chore: update ECOSYSTEM.md [#5077](https://github.com/axios/axios/pull/5077) | ||
- chore: update get/index.html [#5116](https://github.com/axios/axios/pull/5116) | ||
- chore: update Sandbox UI/UX [#5205](https://github.com/axios/axios/pull/5205) | ||
- chore:(actions): remove git credentials after checkout [#5235](https://github.com/axios/axios/pull/5235) | ||
- chore(actions): bump actions/dependency-review-action from 2 to 3 [#5266](https://github.com/axios/axios/pull/5266) | ||
- chore(packages): bump loader-utils from 1.4.1 to 1.4.2 [#5295](https://github.com/axios/axios/pull/5295) | ||
- chore(packages): bump engine.io from 6.2.0 to 6.2.1 [#5294](https://github.com/axios/axios/pull/5294) | ||
- chore(packages): bump socket.io-parser from 4.0.4 to 4.0.5 [#5241](https://github.com/axios/axios/pull/5241) | ||
- chore(packages): bump loader-utils from 1.4.0 to 1.4.1 [#5245](https://github.com/axios/axios/pull/5245) | ||
- chore(docs): update Resources links in README [#5119](https://github.com/axios/axios/pull/5119) | ||
- chore(docs): update the link for JSON url [#5265](https://github.com/axios/axios/pull/5265) | ||
- chore(docs): fix broken links [#5218](https://github.com/axios/axios/pull/5218) | ||
- chore(docs): update and rename UPGRADE_GUIDE.md to MIGRATION_GUIDE.md [#5170](https://github.com/axios/axios/pull/5170) | ||
- chore(docs): typo fix line #856 and #920 [#5194](https://github.com/axios/axios/pull/5194) | ||
- chore(docs): typo fix #800 [#5193](https://github.com/axios/axios/pull/5193) | ||
- chore(docs): fix typos [#5184](https://github.com/axios/axios/pull/5184) | ||
- chore(docs): fix punctuation in README.md [#5197](https://github.com/axios/axios/pull/5197) | ||
- chore(docs): update readme in the Handling Errors section - issue reference #5260 [#5261](https://github.com/axios/axios/pull/5261) | ||
- chore: remove \b from filename [#5207](https://github.com/axios/axios/pull/5207) | ||
- chore(docs): update CHANGELOG.md [#5137](https://github.com/axios/axios/pull/5137) | ||
- chore: add sideEffects false to package.json [#5025](https://github.com/axios/axios/pull/5025) | ||
New Functionality: | ||
### Contributors to this release | ||
- Add getUri method ([#1712](https://github.com/axios/axios/issues/1712)) | ||
- Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693)) | ||
- Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625)) | ||
- Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623)) | ||
- Typings: allow custom return types | ||
- Add option to specify character set in responses (with http adapter) | ||
- [Maddy Miller](https://github.com/me4502) | ||
- [Amit Saini](https://github.com/amitsainii) | ||
- [ecyrbe](https://github.com/ecyrbe) | ||
- [Ikko Ashimine](https://github.com/eltociear) | ||
- [Geeth Gunnampalli](https://github.com/thetechie7) | ||
- [Shreem Asati](https://github.com/shreem-123) | ||
- [Frieder Bluemle](https://github.com/friederbluemle) | ||
- [μ€μΈμ](https://github.com/yunseyeong) | ||
- [Claudio Busatto](https://github.com/cjcbusatto) | ||
- [Remco Haszing](https://github.com/remcohaszing) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Csaba Maulis](https://github.com/om4csaba) | ||
- [MoPaMo](https://github.com/MoPaMo) | ||
- [Daniel Fjeldstad](https://github.com/w3bdesign) | ||
- [Adrien Brunet](https://github.com/adrien-may) | ||
- [Frazer Smith](https://github.com/Fdawgs) | ||
- [HaiTao](https://github.com/836334258) | ||
- [AZM](https://github.com/aziyatali) | ||
- [relbns](https://github.com/relbns) | ||
Fixes: | ||
## [1.1.3] - 2022-10-15 | ||
- Fix Keep defaults local to instance ([#385](https://github.com/axios/axios/issues/385)) | ||
- Correctly catch exception in http test ([#1475](https://github.com/axios/axios/issues/1475)) | ||
- Fix accept header normalization ([#1698](https://github.com/axios/axios/issues/1698)) | ||
- Fix http adapter to allow HTTPS connections via HTTP ([#959](https://github.com/axios/axios/issues/959)) | ||
- Fix Removes usage of deprecated Buffer constructor. ([#1555](https://github.com/axios/axios/issues/1555), [#1622](https://github.com/axios/axios/issues/1622)) | ||
- Fix defaults to use httpAdapter if available ([#1285](https://github.com/axios/axios/issues/1285)) | ||
- Fixing defaults to use httpAdapter if available | ||
- Use a safer, cross-platform method to detect the Node environment | ||
- Fix Reject promise if request is cancelled by the browser ([#537](https://github.com/axios/axios/issues/537)) | ||
- [Typescript] Fix missing type parameters on delete/head methods | ||
- [NS]: Send `false` flag isStandardBrowserEnv for Nativescript | ||
- Fix missing type parameters on delete/head | ||
- Fix Default method for an instance always overwritten by get | ||
- Fix type error when socketPath option in AxiosRequestConfig | ||
- Capture errors on request data streams | ||
- Decorate resolve and reject to clear timeout in all cases | ||
### Added | ||
Huge thanks to everyone who contributed to this release via code (authors listed | ||
below) or via reviews and triaging on GitHub: | ||
- Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113) | ||
- Andrew Scott <ascott18@gmail.com> | ||
- Anthony Gauthier <antho325@hotmail.com> | ||
- arpit <arpit2438735@gmail.com> | ||
- ascott18 | ||
- Benedikt RΓΆtsch <axe312ger@users.noreply.github.com> | ||
- Chance Dickson <me@chancedickson.com> | ||
- Dave Stewart <info@davestewart.co.uk> | ||
- Deric Cain <deric.cain@gmail.com> | ||
- Guillaume Briday <guillaumebriday@gmail.com> | ||
- Jacob Wejendorp <jacob@wejendorp.dk> | ||
- Jim Lynch <mrdotjim@gmail.com> | ||
- johntron | ||
- Justin Beckwith <beckwith@google.com> | ||
- Justin Beckwith <justin.beckwith@gmail.com> | ||
- Khaled Garbaya <khaledgarbaya@gmail.com> | ||
- Lim Jing Rong <jjingrong@users.noreply.github.com> | ||
- Mark van den Broek <mvdnbrk@gmail.com> | ||
- Martti Laine <martti@codeclown.net> | ||
- mattridley | ||
- mattridley <matt.r@joinblink.com> | ||
- Nicolas Del Valle <nicolas.delvalle@gmail.com> | ||
- Nilegfx | ||
- pbarbiero | ||
- Rikki Gibson <rikkigibson@gmail.com> | ||
- Sako Hartounian <sakohartounian@yahoo.com> | ||
- Shane Fitzpatrick <fitzpasd@gmail.com> | ||
- Stephan Schneider <stephanschndr@gmail.com> | ||
- Steven <steven@ceriously.com> | ||
- Tim Garthwaite <tim.garthwaite@jibo.com> | ||
- Tim Johns <timjohns@yahoo.com> | ||
- Yutaro Miyazaki <yutaro@studio-rubbish.com> | ||
### Fixed | ||
### 0.18.0 (Feb 19, 2018) | ||
- Fixed top-level export to keep them in-line with static properties [#5109](https://github.com/axios/axios/pull/5109) | ||
- Stopped including null values to query string. [#5108](https://github.com/axios/axios/pull/5108) | ||
- Restored proxy config backwards compatibility with 0.x [#5097](https://github.com/axios/axios/pull/5097) | ||
- Added back AxiosHeaders in AxiosHeaderValue [#5103](https://github.com/axios/axios/pull/5103) | ||
- Pin CDN install instructions to a specific version [#5060](https://github.com/axios/axios/pull/5060) | ||
- Handling of array values fixed for AxiosHeaders [#5085](https://github.com/axios/axios/pull/5085) | ||
- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070)) | ||
- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)): | ||
- AxiosRequestConfig.proxy: allows type false | ||
- AxiosProxyConfig: added auth field | ||
- Adding function signature in AxiosInstance interface so AxiosInstance can be invoked ([#1192](https://github.com/axios/axios/pull/1192), [#1254](https://github.com/axios/axios/pull/1254)) | ||
- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287)) | ||
- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342)) | ||
### Chores | ||
### 0.17.1 (Nov 11, 2017) | ||
- docs: match badge style, add link to them [#5046](https://github.com/axios/axios/pull/5046) | ||
- chore: fixing comments typo [#5054](https://github.com/axios/axios/pull/5054) | ||
- chore: update issue template [#5061](https://github.com/axios/axios/pull/5061) | ||
- chore: added progress capturing section to the docs; [#5084](https://github.com/axios/axios/pull/5084) | ||
- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160)) | ||
- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080)) | ||
- Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131)) | ||
### Contributors to this release | ||
### 0.17.0 (Oct 21, 2017) | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
- [scarf](https://github.com/scarf005) | ||
- [Lenz Weber-Tronic](https://github.com/phryneas) | ||
- [Arvindh](https://github.com/itsarvindh) | ||
- [FΓ©lix Legrelle](https://github.com/FelixLgr) | ||
- [Patrick Petrovic](https://github.com/ppati000) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [littledian](https://github.com/littledian) | ||
- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime) | ||
- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950)) | ||
- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874)) | ||
- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691)) | ||
- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061)) | ||
## [1.1.2] - 2022-10-07 | ||
### 0.16.2 (Jun 3, 2017) | ||
### Fixed | ||
- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887)) | ||
- Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830)) | ||
- Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930)) | ||
- Fixed broken exports for UMD builds. | ||
### 0.16.1 (Apr 8, 2017) | ||
### Contributors to this release | ||
- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828)) | ||
- Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829)) | ||
- Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773)) | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
### 0.16.0 (Mar 31, 2017) | ||
## [1.1.1] - 2022-10-07 | ||
- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480)) | ||
- Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461)) | ||
- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/axios/axios/pull/654)) | ||
- Improving React Native detection ([#731](https://github.com/axios/axios/pull/731)) | ||
- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581)) | ||
- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561)) | ||
### Fixed | ||
### 0.15.3 (Nov 27, 2016) | ||
- Fixed broken exports for common js. This fix breaks a prior fix, I will fix both issues ASAP but the commonJS use is more impactful. | ||
- Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443)) | ||
- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519)) | ||
- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/axios/axios/issues/509)) | ||
- Fixing issue with `btoa` and IE ([#507](https://github.com/axios/axios/issues/507)) | ||
- Adding support for proxy authentication ([#483](https://github.com/axios/axios/pull/483)) | ||
- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493)) | ||
- Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491)) | ||
### Contributors to this release | ||
### 0.15.2 (Oct 17, 2016) | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482)) | ||
## [1.1.0] - 2022-10-06 | ||
### 0.15.1 (Oct 14, 2016) | ||
### Fixed | ||
- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485)) | ||
- Fixed missing exports in type definition index.d.ts [#5003](https://github.com/axios/axios/pull/5003) | ||
- Fixed query params composing [#5018](https://github.com/axios/axios/pull/5018) | ||
- Fixed GenericAbortSignal interface by making it more generic [#5021](https://github.com/axios/axios/pull/5021) | ||
- Fixed adding "clear" to AxiosInterceptorManager [#5010](https://github.com/axios/axios/pull/5010) | ||
- Fixed commonjs & umd exports [#5030](https://github.com/axios/axios/pull/5030) | ||
- Fixed inability to access response headers when using axios 1.x with Jest [#5036](https://github.com/axios/axios/pull/5036) | ||
### 0.15.0 (Oct 10, 2016) | ||
### Contributors to this release | ||
- Adding cancellation support ([#452](https://github.com/axios/axios/pull/452)) | ||
- Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437)) | ||
- Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440)) | ||
- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445)) | ||
- [Trim21](https://github.com/trim21) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [shingo.sasaki](https://github.com/s-sasaki-0529) | ||
- [Ivan Pepelko](https://github.com/ivanpepelko) | ||
- [Richard KoΕΓnek](https://github.com/risa) | ||
### 0.14.0 (Aug 27, 2016) | ||
## [1.0.0] - 2022-10-04 | ||
- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419)) | ||
- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387)) | ||
- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/axios/axios/pull/423)) | ||
- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/axios/axios/pull/366)) | ||
- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397)) | ||
- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406)) | ||
### Added | ||
### 0.13.1 (Jul 16, 2016) | ||
- Added stack trace to AxiosError [#4624](https://github.com/axios/axios/pull/4624) | ||
- Add AxiosError to AxiosStatic [#4654](https://github.com/axios/axios/pull/4654) | ||
- Replaced Rollup as our build runner [#4596](https://github.com/axios/axios/pull/4596) | ||
- Added generic TS types for the exposed toFormData helper [#4668](https://github.com/axios/axios/pull/4668) | ||
- Added listen callback function [#4096](https://github.com/axios/axios/pull/4096) | ||
- Added instructions for installing using PNPM [#4207](https://github.com/axios/axios/pull/4207) | ||
- Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill [#4229](https://github.com/axios/axios/pull/4229) | ||
- Added axios-url-template in ECOSYSTEM.md [#4238](https://github.com/axios/axios/pull/4238) | ||
- Added a clear() function to the request and response interceptors object so a user can ensure that all interceptors have been removed from an axios instance [#4248](https://github.com/axios/axios/pull/4248) | ||
- Added react hook plugin [#4319](https://github.com/axios/axios/pull/4319) | ||
- Adding HTTP status code for transformResponse [#4580](https://github.com/axios/axios/pull/4580) | ||
- Added blob to the list of protocols supported by the browser [#4678](https://github.com/axios/axios/pull/4678) | ||
- Resolving proxy from env on redirect [#4436](https://github.com/axios/axios/pull/4436) | ||
- Added enhanced toFormData implementation with additional options [4704](https://github.com/axios/axios/pull/4704) | ||
- Adding Canceler parameters config and request [#4711](https://github.com/axios/axios/pull/4711) | ||
- Added automatic payload serialization to application/x-www-form-urlencoded [#4714](https://github.com/axios/axios/pull/4714) | ||
- Added the ability for webpack users to overwrite built-ins [#4715](https://github.com/axios/axios/pull/4715) | ||
- Added string[] to AxiosRequestHeaders type [#4322](https://github.com/axios/axios/pull/4322) | ||
- Added the ability for the url-encoded-form serializer to respect the formSerializer config [#4721](https://github.com/axios/axios/pull/4721) | ||
- Added isCancel type assert [#4293](https://github.com/axios/axios/pull/4293) | ||
- Added data URL support for node.js [#4725](https://github.com/axios/axios/pull/4725) | ||
- Adding types for progress event callbacks [#4675](https://github.com/axios/axios/pull/4675) | ||
- URL params serializer [#4734](https://github.com/axios/axios/pull/4734) | ||
- Added axios.formToJSON method [#4735](https://github.com/axios/axios/pull/4735) | ||
- Bower platform add data protocol [#4804](https://github.com/axios/axios/pull/4804) | ||
- Use WHATWG URL API instead of url.parse() [#4852](https://github.com/axios/axios/pull/4852) | ||
- Add ENUM containing Http Status Codes to typings [#4903](https://github.com/axios/axios/pull/4903) | ||
- Improve typing of timeout in index.d.ts [#4934](https://github.com/axios/axios/pull/4934) | ||
- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378)) | ||
### Changed | ||
### 0.13.0 (Jul 13, 2016) | ||
- Updated AxiosError.config to be optional in the type definition [#4665](https://github.com/axios/axios/pull/4665) | ||
- Updated README emphasizing the URLSearchParam built-in interface over other solutions [#4590](https://github.com/axios/axios/pull/4590) | ||
- Include request and config when creating a CanceledError instance [#4659](https://github.com/axios/axios/pull/4659) | ||
- Changed func-names eslint rule to as-needed [#4492](https://github.com/axios/axios/pull/4492) | ||
- Replacing deprecated substr() with slice() as substr() is deprecated [#4468](https://github.com/axios/axios/pull/4468) | ||
- Updating HTTP links in README.md to use HTTPS [#4387](https://github.com/axios/axios/pull/4387) | ||
- Updated to a better trim() polyfill [#4072](https://github.com/axios/axios/pull/4072) | ||
- Updated types to allow specifying partial default headers on instance create [#4185](https://github.com/axios/axios/pull/4185) | ||
- Expanded isAxiosError types [#4344](https://github.com/axios/axios/pull/4344) | ||
- Updated type definition for axios instance methods [#4224](https://github.com/axios/axios/pull/4224) | ||
- Updated eslint config [#4722](https://github.com/axios/axios/pull/4722) | ||
- Updated Docs [#4742](https://github.com/axios/axios/pull/4742) | ||
- Refactored Axios to use ES2017 [#4787](https://github.com/axios/axios/pull/4787) | ||
- **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345)) | ||
- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)) | ||
- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)) | ||
- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/axios/axios/issues/343)) | ||
- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/axios/axios/issues/352)) | ||
- Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341)) | ||
- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217)) | ||
### 0.12.0 (May 31, 2016) | ||
### Deprecated | ||
- There are multiple deprecations, refactors and fixes provided in this release. Please read through the full release notes to see how this may impact your project and use case. | ||
- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317)) | ||
- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307)) | ||
### Removed | ||
### 0.11.1 (May 17, 2016) | ||
- Removed incorrect argument for NetworkError constructor [#4656](https://github.com/axios/axios/pull/4656) | ||
- Removed Webpack [#4596](https://github.com/axios/axios/pull/4596) | ||
- Removed function that transform arguments to array [#4544](https://github.com/axios/axios/pull/4544) | ||
- Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313)) | ||
- Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325)) | ||
- Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321)) | ||
### Fixed | ||
### 0.11.0 (Apr 26, 2016) | ||
- Fixed grammar in README [#4649](https://github.com/axios/axios/pull/4649) | ||
- Fixed code error in README [#4599](https://github.com/axios/axios/pull/4599) | ||
- Optimized the code that checks cancellation [#4587](https://github.com/axios/axios/pull/4587) | ||
- Fix url pointing to defaults.js in README [#4532](https://github.com/axios/axios/pull/4532) | ||
- Use type alias instead of interface for AxiosPromise [#4505](https://github.com/axios/axios/pull/4505) | ||
- Fix some word spelling and lint style in code comments [#4500](https://github.com/axios/axios/pull/4500) | ||
- Edited readme with 3 updated browser icons of Chrome, FireFox and Safari [#4414](https://github.com/axios/axios/pull/4414) | ||
- Bump follow-redirects from 1.14.9 to 1.15.0 [#4673](https://github.com/axios/axios/pull/4673) | ||
- Fixing http tests to avoid hanging when assertions fail [#4435](https://github.com/axios/axios/pull/4435) | ||
- Fix TS definition for AxiosRequestTransformer [#4201](https://github.com/axios/axios/pull/4201) | ||
- Fix grammatical issues in README [#4232](https://github.com/axios/axios/pull/4232) | ||
- Fixing instance.defaults.headers type [#4557](https://github.com/axios/axios/pull/4557) | ||
- Fixed race condition on immediate requests cancellation [#4261](https://github.com/axios/axios/pull/4261) | ||
- Fixing Z_BUF_ERROR when no content [#4701](https://github.com/axios/axios/pull/4701) | ||
- Fixing proxy beforeRedirect regression [#4708](https://github.com/axios/axios/pull/4708) | ||
- Fixed AxiosError status code type [#4717](https://github.com/axios/axios/pull/4717) | ||
- Fixed AxiosError stack capturing [#4718](https://github.com/axios/axios/pull/4718) | ||
- Fixing AxiosRequestHeaders typings [#4334](https://github.com/axios/axios/pull/4334) | ||
- Fixed max body length defaults [#4731](https://github.com/axios/axios/pull/4731) | ||
- Fixed toFormData Blob issue on node>v17 [#4728](https://github.com/axios/axios/pull/4728) | ||
- Bump grunt from 1.5.2 to 1.5.3 [#4743](https://github.com/axios/axios/pull/4743) | ||
- Fixing content-type header repeated [#4745](https://github.com/axios/axios/pull/4745) | ||
- Fixed timeout error message for http [4738](https://github.com/axios/axios/pull/4738) | ||
- Request ignores false, 0 and empty string as body values [#4785](https://github.com/axios/axios/pull/4785) | ||
- Added back missing minified builds [#4805](https://github.com/axios/axios/pull/4805) | ||
- Fixed a type error [#4815](https://github.com/axios/axios/pull/4815) | ||
- Fixed a regression bug with unsubscribing from cancel token; [#4819](https://github.com/axios/axios/pull/4819) | ||
- Remove repeated compression algorithm [#4820](https://github.com/axios/axios/pull/4820) | ||
- The error of calling extend to pass parameters [#4857](https://github.com/axios/axios/pull/4857) | ||
- SerializerOptions.indexes allows boolean | null | undefined [#4862](https://github.com/axios/axios/pull/4862) | ||
- Require interceptors to return values [#4874](https://github.com/axios/axios/pull/4874) | ||
- Removed unused imports [#4949](https://github.com/axios/axios/pull/4949) | ||
- Allow null indexes on formSerializer and paramsSerializer [#4960](https://github.com/axios/axios/pull/4960) | ||
- Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296)) | ||
- Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308)) | ||
- Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299)) | ||
### Chores | ||
- Set permissions for GitHub actions [#4765](https://github.com/axios/axios/pull/4765) | ||
- Included githubactions in the dependabot config [#4770](https://github.com/axios/axios/pull/4770) | ||
- Included dependency review [#4771](https://github.com/axios/axios/pull/4771) | ||
- Update security.md [#4784](https://github.com/axios/axios/pull/4784) | ||
- Remove unnecessary spaces [#4854](https://github.com/axios/axios/pull/4854) | ||
- Simplify the import path of AxiosError [#4875](https://github.com/axios/axios/pull/4875) | ||
- Fix Gitpod dead link [#4941](https://github.com/axios/axios/pull/4941) | ||
- Enable syntax highlighting for a code block [#4970](https://github.com/axios/axios/pull/4970) | ||
- Using Logo Axios in Readme.md [#4993](https://github.com/axios/axios/pull/4993) | ||
- Fix markup for note in README [#4825](https://github.com/axios/axios/pull/4825) | ||
- Fix typo and formatting, add colons [#4853](https://github.com/axios/axios/pull/4853) | ||
- Fix typo in readme [#4942](https://github.com/axios/axios/pull/4942) | ||
### 0.10.0 (Apr 20, 2016) | ||
### Security | ||
- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250)) | ||
- Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252)) | ||
- Fixing request timeout for XHR adapter ([#227](https://github.com/axios/axios/pull/227)) | ||
- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/axios/axios/pull/249)) | ||
- Fixing IE9 cross domain requests ([#251](https://github.com/axios/axios/pull/251)) | ||
- Adding `maxContentLength` option ([#275](https://github.com/axios/axios/pull/275)) | ||
- Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279)) | ||
- Adding request instance to response ([#200](https://github.com/axios/axios/pull/200)) | ||
- Update SECURITY.md [#4687](https://github.com/axios/axios/pull/4687) | ||
### 0.9.1 (Jan 24, 2016) | ||
### Contributors to this release | ||
- Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124)) | ||
- Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205)) | ||
- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201)) | ||
- Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198)) | ||
- [Bertrand Marron](https://github.com/tusbar) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Dan Mooney](https://github.com/danmooney) | ||
- [Michael Li](https://github.com/xiaoyu-tamu) | ||
- [aong](https://github.com/yxwzaxns) | ||
- [Des Preston](https://github.com/despreston) | ||
- [Ted Robertson](https://github.com/tredondo) | ||
- [zhoulixiang](https://github.com/zh-lx) | ||
- [Arthur Fiorette](https://github.com/arthurfiorette) | ||
- [Kumar Shanu](https://github.com/Kr-Shanu) | ||
- [JALAL](https://github.com/JLL32) | ||
- [Jingyi Lin](https://github.com/MageeLin) | ||
- [Philipp Loose](https://github.com/phloose) | ||
- [Alexander Shchukin](https://github.com/sashsvamir) | ||
- [Dave Cardwell](https://github.com/davecardwell) | ||
- [Cat Scarlet](https://github.com/catscarlet) | ||
- [Luca Pizzini](https://github.com/lpizzinidev) | ||
- [Kai](https://github.com/Schweinepriester) | ||
- [Maxime Bargiel](https://github.com/mbargiel) | ||
- [Brian Helba](https://github.com/brianhelba) | ||
- [reslear](https://github.com/reslear) | ||
- [Jamie Slome](https://github.com/JamieSlome) | ||
- [Landro3](https://github.com/Landro3) | ||
- [rafw87](https://github.com/rafw87) | ||
- [Afzal Sayed](https://github.com/afzalsayed96) | ||
- [Koki Oyatsu](https://github.com/kaishuu0123) | ||
- [Dave](https://github.com/wangcch) | ||
- [ζ΄θ΅°θδΈ](https://github.com/baozouai) | ||
- [Spencer](https://github.com/spalger) | ||
- [Adrian Wieprzkowicz](https://github.com/Argeento) | ||
- [Jamie Telin](https://github.com/lejahmie) | ||
- [ζ―ε](https://github.com/aweikalee) | ||
- [Kirill Shakirov](https://github.com/turisap) | ||
- [Rraji Abdelbari](https://github.com/estarossa0) | ||
- [Jelle Schutter](https://github.com/jelleschutter) | ||
- [Tom Ceuppens](https://github.com/KyorCode) | ||
- [Johann Cooper](https://github.com/JohannCooper) | ||
- [Dimitris Halatsis](https://github.com/mitsos1os) | ||
- [chenjigeng](https://github.com/chenjigeng) | ||
- [JoΓ£o Gabriel Quaresma](https://github.com/joaoGabriel55) | ||
- [Victor Augusto](https://github.com/VictorAugDB) | ||
- [neilnaveen](https://github.com/neilnaveen) | ||
- [Pavlos](https://github.com/psmoros) | ||
- [Kiryl Valkovich](https://github.com/visortelle) | ||
- [Naveen](https://github.com/naveensrinivasan) | ||
- [wenzheng](https://github.com/0x30) | ||
- [hcwhan](https://github.com/hcwhan) | ||
- [Bassel Rachid](https://github.com/basselworkforce) | ||
- [GrΓ©goire Pineau](https://github.com/lyrixx) | ||
- [felipedamin](https://github.com/felipedamin) | ||
- [Karl Horky](https://github.com/karlhorky) | ||
- [Yue JIN](https://github.com/kingyue737) | ||
- [Usman Ali Siddiqui](https://github.com/usman250994) | ||
- [WD](https://github.com/techbirds) | ||
- [GΓΌnther Foidl](https://github.com/gfoidl) | ||
- [Stephen Jennings](https://github.com/jennings) | ||
- [C.T.Lin](https://github.com/chentsulin) | ||
- [mia-z](https://github.com/mia-z) | ||
- [Parth Banathia](https://github.com/Parth0105) | ||
- [parth0105pluang](https://github.com/parth0105pluang) | ||
- [Marco Weber](https://github.com/mrcwbr) | ||
- [Luca Pizzini](https://github.com/lpizzinidev) | ||
- [Willian Agostini](https://github.com/WillianAgostini) | ||
- [Huyen Nguyen](https://github.com/huyenltnguyen) | ||
### 0.9.0 (Jan 18, 2016) | ||
- Adding support for custom adapters | ||
- Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195)) | ||
- Improving XDomainRequest implementation ([#185](https://github.com/axios/axios/pull/185)) | ||
- Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183)) | ||
- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182)) | ||
### 0.8.1 (Dec 14, 2015) | ||
- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168)) | ||
- Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173)) | ||
- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174)) | ||
### 0.8.0 (Dec 11, 2015) | ||
- Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123)) | ||
- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128)) | ||
- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/axios/axios/pull/121)) | ||
- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/axios/axios/pull/127)) | ||
- Adding support for following redirects in node ([#146](https://github.com/axios/axios/pull/146)) | ||
- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/axios/axios/pull/149)) | ||
- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/axios/axios/pull/140)) | ||
- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167)) | ||
- Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160)) | ||
### 0.7.0 (Sep 29, 2015) | ||
- Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87)) | ||
- Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102)) | ||
- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/axios/axios/pull/106)) | ||
- Fixing typescript definition ([#105](https://github.com/axios/axios/pull/105)) | ||
- Fixing default timeout config for node ([#112](https://github.com/axios/axios/pull/112)) | ||
- Adding support for use in web workers, and react-native ([#70](https://github.com/axios/axios/issue/70)), ([#98](https://github.com/axios/axios/pull/98)) | ||
- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116)) | ||
### 0.6.0 (Sep 21, 2015) | ||
- Removing deprecated success/error aliases | ||
- Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49)) | ||
- Fixing issue with User-Agent getting overridden ([#69](https://github.com/axios/axios/issues/69)) | ||
- Adding support for timeout config ([#56](https://github.com/axios/axios/issues/56)) | ||
- Removing es6-promise dependency | ||
- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/axios/axios/pull/91)) | ||
- Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85)) | ||
- Converting build to UMD | ||
### 0.5.4 (Apr 08, 2015) | ||
- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53)) | ||
### 0.5.3 (Apr 07, 2015) | ||
- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55)) | ||
### 0.5.2 (Mar 13, 2015) | ||
- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46)) | ||
### 0.5.1 (Mar 10, 2015) | ||
- Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45)) | ||
- Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47)) | ||
### 0.5.0 (Jan 23, 2015) | ||
- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14)) | ||
- Updating es6-promise dependency | ||
### 0.4.2 (Dec 10, 2014) | ||
- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22)) | ||
- Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25)) | ||
- Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29)) | ||
- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30)) | ||
### 0.4.1 (Oct 15, 2014) | ||
- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18)) | ||
### 0.4.0 (Oct 03, 2014) | ||
- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10)) | ||
- Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13)) | ||
- Adding support for SSL for node.js ([#12](https://github.com/axios/axios/issues/12)) | ||
- Fixing incorrect `Content-Type` header ([#9](https://github.com/axios/axios/issues/9)) | ||
- Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11)) | ||
- Deprecating `success`/`error` in favor of `then`/`catch` | ||
### 0.3.1 (Sep 16, 2014) | ||
- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3)) | ||
### 0.3.0 (Sep 16, 2014) | ||
- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8)) | ||
- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6)) | ||
- Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7)) | ||
### 0.2.2 (Sep 14, 2014) | ||
- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4)) | ||
### 0.2.1 (Sep 12, 2014) | ||
- Fixing build problem causing ridiculous file sizes | ||
### 0.2.0 (Sep 12, 2014) | ||
- Adding support for `all` and `spread` | ||
- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1)) | ||
### 0.1.0 (Aug 29, 2014) | ||
- Initial release |
@@ -1,2 +0,3 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){return function(){return e.apply(t,arguments)}}var s,u=Object.prototype.toString,c=Object.getPrototypeOf,f=(s=Object.create(null),function(e){var t=u.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())}),l=function(e){return e=e.toLowerCase(),function(t){return f(t)===e}},d=function(t){return function(n){return e(n)===t}},p=Array.isArray,h=d("undefined");var m=l("ArrayBuffer");var y=d("string"),v=d("function"),b=d("number"),g=function(t){return null!==t&&"object"===e(t)},w=function(e){if("object"!==f(e))return!1;var t=c(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},E=l("Date"),O=l("File"),S=l("Blob"),R=l("FileList"),A=l("URLSearchParams");function T(t,n){var r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=i.allOwnKeys,s=void 0!==a&&a;if(null!=t)if("object"!==e(t)&&(t=[t]),p(t))for(r=0,o=t.length;r<o;r++)n.call(null,t[r],r,t);else{var u,c=s?Object.getOwnPropertyNames(t):Object.keys(t),f=c.length;for(r=0;r<f;r++)u=c[r],n.call(null,t[u],u,t)}}function j(e,t){t=t.toLowerCase();for(var n,r=Object.keys(e),o=r.length;o-- >0;)if(t===(n=r[o]).toLowerCase())return n;return null}var N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,C=function(e){return!h(e)&&e!==N};var x,P=(x="undefined"!=typeof Uint8Array&&c(Uint8Array),function(e){return x&&e instanceof x}),k=l("HTMLFormElement"),U=function(e){var t=Object.prototype.hasOwnProperty;return function(e,n){return t.call(e,n)}}(),_=l("RegExp"),F=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};T(n,(function(n,o){!1!==t(n,o,e)&&(r[o]=n)})),Object.defineProperties(e,r)},B="abcdefghijklmnopqrstuvwxyz",L="0123456789",D={DIGIT:L,ALPHA:B,ALPHA_DIGIT:B+B.toUpperCase()+L};var I=l("AsyncFunction"),q={isArray:p,isArrayBuffer:m,isBuffer:function(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&v(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||v(e.append)&&("formdata"===(t=f(e))||"object"===t&&v(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&m(e.buffer)},isString:y,isNumber:b,isBoolean:function(e){return!0===e||!1===e},isObject:g,isPlainObject:w,isUndefined:h,isDate:E,isFile:O,isBlob:S,isRegExp:_,isFunction:v,isStream:function(e){return g(e)&&v(e.pipe)},isURLSearchParams:A,isTypedArray:P,isFileList:R,forEach:T,merge:function e(){for(var t=C(this)&&this||{},n=t.caseless,r={},o=function(t,o){var i=n&&j(r,o)||o;w(r[i])&&w(t)?r[i]=e(r[i],t):w(t)?r[i]=e({},t):p(t)?r[i]=t.slice():r[i]=t},i=0,a=arguments.length;i<a;i++)arguments[i]&&T(arguments[i],o);return r},extend:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.allOwnKeys;return T(t,(function(t,r){n&&v(t)?e[r]=a(t,n):e[r]=t}),{allOwnKeys:o}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var o,i,a,s={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&c(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:f,kindOfTest:l,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(p(e))return e;var t=e.length;if(!b(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var o=n.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:k,hasOwnProperty:U,hasOwnProp:U,reduceDescriptors:F,freezeMethods:function(e){F(e,(function(t,n){if(v(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;var r=e[n];v(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=function(){throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:function(e,t){var n={},r=function(e){e.forEach((function(e){n[e]=!0}))};return p(e)?r(e):r(String(e).split(t)),n},toCamelCase:function(e){return e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))},noop:function(){},toFiniteNumber:function(e,t){return e=+e,Number.isFinite(e)?e:t},findKey:j,global:N,isContextDefined:C,ALPHABET:D,generateString:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D.ALPHA_DIGIT,n="",r=t.length;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&v(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:function(e){var t=new Array(10);return function e(n,r){if(g(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[r]=n;var o=p(n)?[]:{};return T(n,(function(t,n){var i=e(t,r+1);!h(i)&&(o[n]=i)})),t[r]=void 0,o}}return n}(e,0)},isAsyncFn:I,isThenable:function(e){return e&&(g(e)||v(e))&&v(e.then)&&v(e.catch)}};function M(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}q.inherits(M,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:q.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var z=M.prototype,H={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){H[e]={value:e}})),Object.defineProperties(M,H),Object.defineProperty(z,"isAxiosError",{value:!0}),M.from=function(e,t,n,r,o,i){var a=Object.create(z);return q.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(function(e){return"isAxiosError"!==e})),M.call(a,e.message,t,n,r,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};function J(e){return q.isPlainObject(e)||q.isArray(e)}function W(e){return q.endsWith(e,"[]")?e.slice(0,-2):e}function K(e,t,n){return e?e.concat(t).map((function(e,t){return e=W(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}var V=q.toFlatObject(q,{},null,(function(e){return/^is[A-Z]/.test(e)}));function G(t,n,r){if(!q.isObject(t))throw new TypeError("target must be an object");n=n||new FormData;var o=(r=q.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!q.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,u=(r.Blob||"undefined"!=typeof Blob&&Blob)&&q.isSpecCompliantForm(n);if(!q.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(q.isDate(e))return e.toISOString();if(!u&&q.isBlob(e))throw new M("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(e)||q.isTypedArray(e)?u&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(t,r,i){var u=t;if(t&&!i&&"object"===e(t))if(q.endsWith(r,"{}"))r=o?r:r.slice(0,-2),t=JSON.stringify(t);else if(q.isArray(t)&&function(e){return q.isArray(e)&&!e.some(J)}(t)||(q.isFileList(t)||q.endsWith(r,"[]"))&&(u=q.toArray(t)))return r=W(r),u.forEach((function(e,t){!q.isUndefined(e)&&null!==e&&n.append(!0===s?K([r],t,a):null===s?r:r+"[]",c(e))})),!1;return!!J(t)||(n.append(K(i,r,a),c(t)),!1)}var l=[],d=Object.assign(V,{defaultVisitor:f,convertValue:c,isVisitable:J});if(!q.isObject(t))throw new TypeError("data must be an object");return function e(t,r){if(!q.isUndefined(t)){if(-1!==l.indexOf(t))throw Error("Circular reference detected in "+r.join("."));l.push(t),q.forEach(t,(function(t,o){!0===(!(q.isUndefined(t)||null===t)&&i.call(n,t,q.isString(o)?o.trim():o,r,d))&&e(t,r?r.concat(o):[o])})),l.pop()}}(t),n}function $(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function X(e,t){this._pairs=[],e&&G(e,this,t)}var Q=X.prototype;function Z(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Y(e,t,n){if(!t)return e;var r,o=n&&n.encode||Z,i=n&&n.serialize;if(r=i?i(t,n):q.isURLSearchParams(t)?t.toString():new X(t,n).toString(o)){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}Q.append=function(e,t){this._pairs.push([e,t])},Q.toString=function(e){var t=e?function(t){return e.call(this,t,$)}:$;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ee,te=function(){function e(){t(this,e),this.handlers=[]}return r(e,[{key:"use",value:function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}},{key:"eject",value:function(e){this.handlers[e]&&(this.handlers[e]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(e){q.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}]),e}(),ne={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},re={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:X,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:("undefined"==typeof navigator||"ReactNative"!==(ee=navigator.product)&&"NativeScript"!==ee&&"NS"!==ee)&&"undefined"!=typeof window&&"undefined"!=typeof document,isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function oe(e){function t(e,n,r,o){var i=e[o++],a=Number.isFinite(+i),s=o>=e.length;return i=!i&&q.isArray(r)?r.length:i,s?(q.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a):(r[i]&&q.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&q.isArray(r[i])&&(r[i]=function(e){var t,n,r={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)r[n=o[t]]=e[n];return r}(r[i])),!a)}if(q.isFormData(e)&&q.isFunction(e.entries)){var n={};return q.forEachEntry(e,(function(e,r){t(function(e){return q.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),r,n,0)})),n}return null}var ie={"Content-Type":void 0};var ae={transitional:ne,adapter:["xhr","http"],transformRequest:[function(e,t){var n,r=t.getContentType()||"",o=r.indexOf("application/json")>-1,i=q.isObject(e);if(i&&q.isHTMLForm(e)&&(e=new FormData(e)),q.isFormData(e))return o&&o?JSON.stringify(oe(e)):e;if(q.isArrayBuffer(e)||q.isBuffer(e)||q.isStream(e)||q.isFile(e)||q.isBlob(e))return e;if(q.isArrayBufferView(e))return e.buffer;if(q.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return G(e,new re.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return re.isNode&&q.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((n=q.isFileList(e))||r.indexOf("multipart/form-data")>-1){var a=this.env&&this.env.FormData;return G(n?{"files[]":e}:e,a&&new a,this.formSerializer)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(q.isString(e))try{return(t||JSON.parse)(e),q.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||ae.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&q.isString(e)&&(n&&!this.responseType||r)){var o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw M.from(e,M.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:re.classes.FormData,Blob:re.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};q.forEach(["delete","get","head"],(function(e){ae.headers[e]={}})),q.forEach(["post","put","patch"],(function(e){ae.headers[e]=q.merge(ie)}));var se=ae,ue=q.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ce=Symbol("internals");function fe(e){return e&&String(e).trim().toLowerCase()}function le(e){return!1===e||null==e?e:q.isArray(e)?e.map(le):String(e)}function de(e,t,n,r,o){return q.isFunction(r)?r.call(this,t,n):(o&&(t=n),q.isString(t)?q.isString(r)?-1!==t.indexOf(r):q.isRegExp(r)?r.test(t):void 0:void 0)}var pe=function(e,n){function i(e){t(this,i),e&&this.set(e)}return r(i,[{key:"set",value:function(e,t,n){var r=this;function o(e,t,n){var o=fe(t);if(!o)throw new Error("header name must be a non-empty string");var i=q.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=le(e))}var i,a,s,u,c,f=function(e,t){return q.forEach(e,(function(e,n){return o(e,n,t)}))};return q.isPlainObject(e)||e instanceof this.constructor?f(e,t):q.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?f((c={},(i=e)&&i.split("\n").forEach((function(e){u=e.indexOf(":"),a=e.substring(0,u).trim().toLowerCase(),s=e.substring(u+1).trim(),!a||c[a]&&ue[a]||("set-cookie"===a?c[a]?c[a].push(s):c[a]=[s]:c[a]=c[a]?c[a]+", "+s:s)})),c),t):null!=e&&o(t,e,n),this}},{key:"get",value:function(e,t){if(e=fe(e)){var n=q.findKey(this,e);if(n){var r=this[n];if(!t)return r;if(!0===t)return function(e){for(var t,n=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;t=r.exec(e);)n[t[1]]=t[2];return n}(r);if(q.isFunction(t))return t.call(this,r,n);if(q.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(e,t){if(e=fe(e)){var n=q.findKey(this,e);return!(!n||void 0===this[n]||t&&!de(0,this[n],n,t))}return!1}},{key:"delete",value:function(e,t){var n=this,r=!1;function o(e){if(e=fe(e)){var o=q.findKey(n,e);!o||t&&!de(0,n[o],o,t)||(delete n[o],r=!0)}}return q.isArray(e)?e.forEach(o):o(e),r}},{key:"clear",value:function(e){for(var t=Object.keys(this),n=t.length,r=!1;n--;){var o=t[n];e&&!de(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}},{key:"normalize",value:function(e){var t=this,n={};return q.forEach(this,(function(r,o){var i=q.findKey(n,o);if(i)return t[i]=le(r),void delete t[o];var a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))}(o):String(o).trim();a!==o&&delete t[o],t[a]=le(r),n[a]=!0})),this}},{key:"concat",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=this.constructor).concat.apply(e,[this].concat(n))}},{key:"toJSON",value:function(e){var t=Object.create(null);return q.forEach(this,(function(n,r){null!=n&&!1!==n&&(t[r]=e&&q.isArray(n)?n.join(", "):n)})),t}},{key:Symbol.iterator,value:function(){return Object.entries(this.toJSON())[Symbol.iterator]()}},{key:"toString",value:function(){return Object.entries(this.toJSON()).map((function(e){var t=o(e,2);return t[0]+": "+t[1]})).join("\n")}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(e){return e instanceof this?e:new this(e)}},{key:"concat",value:function(e){for(var t=new this(e),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.forEach((function(e){return t.set(e)})),t}},{key:"accessor",value:function(e){var t=(this[ce]=this[ce]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=fe(e);t[r]||(!function(e,t){var n=q.toCamelCase(" "+t);["get","set","has"].forEach((function(r){Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return q.isArray(e)?e.forEach(r):r(e),this}}]),i}();pe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),q.freezeMethods(pe.prototype),q.freezeMethods(pe);var he=pe;function me(e,t){var n=this||se,r=t||n,o=he.from(r.headers),i=r.data;return q.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function ye(e){return!(!e||!e.__CANCEL__)}function ve(e,t,n){M.call(this,null==e?"canceled":e,M.ERR_CANCELED,t,n),this.name="CanceledError"}q.inherits(ve,M,{__CANCEL__:!0});var be=re.isStandardBrowserEnv?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),q.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),q.isString(r)&&a.push("path="+r),q.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function ge(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var we=re.isStandardBrowserEnv?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=q.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0};function Ee(e,t){var n=0,r=function(e,t){e=e||10;var n,r=new Array(e),o=new Array(e),i=0,a=0;return t=void 0!==t?t:1e3,function(s){var u=Date.now(),c=o[a];n||(n=u),r[i]=s,o[i]=u;for(var f=a,l=0;f!==i;)l+=r[f++],f%=e;if((i=(i+1)%e)===a&&(a=(a+1)%e),!(u-n<t)){var d=c&&u-c;return d?Math.round(1e3*l/d):void 0}}}(50,250);return function(o){var i=o.loaded,a=o.lengthComputable?o.total:void 0,s=i-n,u=r(s);n=i;var c={loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:u||void 0,estimated:u&&a&&i<=a?(a-i)/u:void 0,event:o};c[t?"download":"upload"]=!0,e(c)}}var Oe={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){var r,o=e.data,i=he.from(e.headers).normalize(),a=e.responseType;function s(){e.cancelToken&&e.cancelToken.unsubscribe(r),e.signal&&e.signal.removeEventListener("abort",r)}q.isFormData(o)&&(re.isStandardBrowserEnv||re.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(c+":"+f))}var l=ge(e.baseURL,e.url);function d(){if(u){var r=he.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders());!function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new M("Request failed with status code "+n.status,[M.ERR_BAD_REQUEST,M.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),s()}),(function(e){n(e),s()}),{data:a&&"text"!==a&&"json"!==a?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:r,config:e,request:u}),u=null}}if(u.open(e.method.toUpperCase(),Y(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=d:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(d)},u.onabort=function(){u&&(n(new M("Request aborted",M.ECONNABORTED,e,u)),u=null)},u.onerror=function(){n(new M("Network Error",M.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||ne;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new M(t,r.clarifyTimeoutError?M.ETIMEDOUT:M.ECONNABORTED,e,u)),u=null},re.isStandardBrowserEnv){var p=(e.withCredentials||we(l))&&e.xsrfCookieName&&be.read(e.xsrfCookieName);p&&i.set(e.xsrfHeaderName,p)}void 0===o&&i.setContentType(null),"setRequestHeader"in u&&q.forEach(i.toJSON(),(function(e,t){u.setRequestHeader(t,e)})),q.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&"json"!==a&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",Ee(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",Ee(e.onUploadProgress)),(e.cancelToken||e.signal)&&(r=function(t){u&&(n(!t||t.type?new ve(null,e,u):t),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(r),e.signal&&(e.signal.aborted?r():e.signal.addEventListener("abort",r)));var h,m=(h=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l))&&h[1]||"";m&&-1===re.protocols.indexOf(m)?n(new M("Unsupported protocol "+m+":",M.ERR_BAD_REQUEST,e)):u.send(o||null)}))}};q.forEach(Oe,(function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var Se=function(e){for(var t,n,r=(e=q.isArray(e)?e:[e]).length,o=0;o<r&&(t=e[o],!(n=q.isString(t)?Oe[t.toLowerCase()]:t));o++);if(!n){if(!1===n)throw new M("Adapter ".concat(t," is not supported by the environment"),"ERR_NOT_SUPPORT");throw new Error(q.hasOwnProp(Oe,t)?"Adapter '".concat(t,"' is not available in the build"):"Unknown adapter '".concat(t,"'"))}if(!q.isFunction(n))throw new TypeError("adapter is not a function");return n};function Re(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ve(null,e)}function Ae(e){return Re(e),e.headers=he.from(e.headers),e.data=me.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Se(e.adapter||se.adapter)(e).then((function(t){return Re(e),t.data=me.call(e,e.transformResponse,t),t.headers=he.from(t.headers),t}),(function(t){return ye(t)||(Re(e),t&&t.response&&(t.response.data=me.call(e,e.transformResponse,t.response),t.response.headers=he.from(t.response.headers))),Promise.reject(t)}))}var Te=function(e){return e instanceof he?e.toJSON():e};function je(e,t){t=t||{};var n={};function r(e,t,n){return q.isPlainObject(e)&&q.isPlainObject(t)?q.merge.call({caseless:n},e,t):q.isPlainObject(t)?q.merge({},t):q.isArray(t)?t.slice():t}function o(e,t,n){return q.isUndefined(t)?q.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function i(e,t){if(!q.isUndefined(t))return r(void 0,t)}function a(e,t){return q.isUndefined(t)?q.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function s(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}var u={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:function(e,t){return o(Te(e),Te(t),!0)}};return q.forEach(Object.keys(Object.assign({},e,t)),(function(r){var i=u[r]||o,a=i(e[r],t[r],r);q.isUndefined(a)&&i!==s||(n[r]=a)})),n}var Ne="1.4.0",Ce={};["object","boolean","number","function","string","symbol"].forEach((function(t,n){Ce[t]=function(r){return e(r)===t||"a"+(n<1?"n ":" ")+t}}));var xe={};Ce.transitional=function(e,t,n){function r(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,o,i){if(!1===e)throw new M(r(o," has been removed"+(t?" in "+t:"")),M.ERR_DEPRECATED);return t&&!xe[o]&&(xe[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};var Pe={assertOptions:function(t,n,r){if("object"!==e(t))throw new M("options must be an object",M.ERR_BAD_OPTION_VALUE);for(var o=Object.keys(t),i=o.length;i-- >0;){var a=o[i],s=n[a];if(s){var u=t[a],c=void 0===u||s(u,a,t);if(!0!==c)throw new M("option "+a+" must be "+c,M.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new M("Unknown option "+a,M.ERR_BAD_OPTION)}},validators:Ce},ke=Pe.validators,Ue=function(){function e(n){t(this,e),this.defaults=n,this.interceptors={request:new te,response:new te}}return r(e,[{key:"request",value:function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};var n,r=t=je(this.defaults,t),o=r.transitional,i=r.paramsSerializer,a=r.headers;void 0!==o&&Pe.assertOptions(o,{silentJSONParsing:ke.transitional(ke.boolean),forcedJSONParsing:ke.transitional(ke.boolean),clarifyTimeoutError:ke.transitional(ke.boolean)},!1),null!=i&&(q.isFunction(i)?t.paramsSerializer={serialize:i}:Pe.assertOptions(i,{encode:ke.function,serialize:ke.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),(n=a&&q.merge(a.common,a[t.method]))&&q.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete a[e]})),t.headers=he.concat(n,a);var s=[],u=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(u=u&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));var c,f=[];this.interceptors.response.forEach((function(e){f.push(e.fulfilled,e.rejected)}));var l,d=0;if(!u){var p=[Ae.bind(this),void 0];for(p.unshift.apply(p,s),p.push.apply(p,f),l=p.length,c=Promise.resolve(t);d<l;)c=c.then(p[d++],p[d++]);return c}l=s.length;var h=t;for(d=0;d<l;){var m=s[d++],y=s[d++];try{h=m(h)}catch(e){y.call(this,e);break}}try{c=Ae.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,l=f.length;d<l;)c=c.then(f[d++],f[d++]);return c}},{key:"getUri",value:function(e){return Y(ge((e=je(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}]),e}();q.forEach(["delete","get","head","options"],(function(e){Ue.prototype[e]=function(t,n){return this.request(je(n||{},{method:e,url:t,data:(n||{}).data}))}})),q.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(je(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Ue.prototype[e]=t(),Ue.prototype[e+"Form"]=t(!0)}));var _e=Ue,Fe=function(){function e(n){if(t(this,e),"function"!=typeof n)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var o=this;this.promise.then((function(e){if(o._listeners){for(var t=o._listeners.length;t-- >0;)o._listeners[t](e);o._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){o.subscribe(e),t=e})).then(e);return n.cancel=function(){o.unsubscribe(t)},n},n((function(e,t,n){o.reason||(o.reason=new ve(e,t,n),r(o.reason))}))}return r(e,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}},{key:"unsubscribe",value:function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}}}],[{key:"source",value:function(){var t;return{token:new e((function(e){t=e})),cancel:t}}}]),e}();var Be={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Be).forEach((function(e){var t=o(e,2),n=t[0],r=t[1];Be[r]=n}));var Le=Be;var De=function e(t){var n=new _e(t),r=a(_e.prototype.request,n);return q.extend(r,_e.prototype,n,{allOwnKeys:!0}),q.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(je(t,n))},r}(se);return De.Axios=_e,De.CanceledError=ve,De.CancelToken=Fe,De.isCancel=ye,De.VERSION=Ne,De.toFormData=G,De.AxiosError=M,De.Cancel=De.CanceledError,De.all=function(e){return Promise.all(e)},De.spread=function(e){return function(t){return e.apply(null,t)}},De.isAxiosError=function(e){return q.isObject(e)&&!0===e.isAxiosError},De.mergeConfig=je,De.AxiosHeaders=he,De.formToJSON=function(e){return oe(q.isHTMLForm(e)?new FormData(e):e)},De.HttpStatusCode=Le,De.default=De,De})); | ||
//# sourceMappingURL=axios.min.js.map | ||
/* axios v0.27.2 | (c) 2022 by Matt Zabriskie */ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t,n){"use strict";var r,o=n(4),i=Object.prototype.toString,s=(r=Object.create(null),function(e){var t=i.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())});function a(e){return e=e.toLowerCase(),function(t){return s(t)===e}}function u(e){return Array.isArray(e)}function c(e){return void 0===e}var f=a("ArrayBuffer");function l(e){return null!==e&&"object"==typeof e}function p(e){if("object"!==s(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var d=a("Date"),h=a("File"),m=a("Blob"),v=a("FileList");function y(e){return"[object Function]"===i.call(e)}var g=a("URLSearchParams");function E(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),u(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var b,O=(b="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return b&&e instanceof b});e.exports={isArray:u,isArrayBuffer:f,isBuffer:function(e){return null!==e&&!c(e)&&null!==e.constructor&&!c(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return e&&("function"==typeof FormData&&e instanceof FormData||"[object FormData]"===i.call(e)||y(e.toString)&&"[object FormData]"===e.toString())},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&f(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:l,isPlainObject:p,isUndefined:c,isDate:d,isFile:h,isBlob:m,isFunction:y,isStream:function(e){return l(e)&&y(e.pipe)},isURLSearchParams:g,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:E,merge:function e(){var t={};function n(n,r){p(t[r])&&p(n)?t[r]=e(t[r],n):p(n)?t[r]=e({},n):u(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)E(arguments[r],n);return t},extend:function(e,t,n){return E(t,(function(t,r){e[r]=n&&"function"==typeof t?o(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n){var r,o,i,s={};t=t||{};do{for(o=(r=Object.getOwnPropertyNames(e)).length;o-- >0;)s[i=r[o]]||(t[i]=e[i],s[i]=!0);e=Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:a,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;var t=e.length;if(c(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:O,isFileList:v}},function(e,t,n){"use strict";var r=n(0);function o(e,t,n,r,o){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}r.inherits(o,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var i=o.prototype,s={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){s[e]={value:e}})),Object.defineProperties(o,s),Object.defineProperty(i,"isAxiosError",{value:!0}),o.from=function(e,t,n,s,a,u){var c=Object.create(i);return r.toFlatObject(e,c,(function(e){return e!==Error.prototype})),o.call(c,e.message,t,n,s,a),c.name=e.name,u&&Object.assign(c,u),c},e.exports=o},function(e,t,n){"use strict";var r=n(1);function o(e){r.call(this,null==e?"canceled":e,r.ERR_CANCELED),this.name="CanceledError"}n(0).inherits(o,r,{__CANCEL__:!0}),e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(19),i=n(1),s=n(6),a=n(7),u={"Content-Type":"application/x-www-form-urlencoded"};function c(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var f,l={transitional:s,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(f=n(8)),f),transformRequest:[function(e,t){if(o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e))return e;if(r.isArrayBufferView(e))return e.buffer;if(r.isURLSearchParams(e))return c(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,i=r.isObject(e),s=t&&t["Content-Type"];if((n=r.isFileList(e))||i&&"multipart/form-data"===s){var u=this.env&&this.env.FormData;return a(n?{"files[]":e}:e,u&&new u)}return i||"application/json"===s?(c(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(t||JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||l.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||o&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i.from(e,i.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:n(27)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){l.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){l.headers[e]=r.merge(u)})),e.exports=l},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,n){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||new FormData;var n=[];function o(e){return null===e?"":r.isDate(e)?e.toISOString():r.isArrayBuffer(e)||r.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}return function e(i,s){if(r.isPlainObject(i)||r.isArray(i)){if(-1!==n.indexOf(i))throw Error("Circular reference detected in "+s);n.push(i),r.forEach(i,(function(n,i){if(!r.isUndefined(n)){var a,u=s?s+"."+i:i;if(n&&!s&&"object"==typeof n)if(r.endsWith(i,"{}"))n=JSON.stringify(n);else if(r.endsWith(i,"[]")&&(a=r.toArray(n)))return void a.forEach((function(e){!r.isUndefined(e)&&t.append(u,o(e))}));e(n,u)}})),n.pop()}else t.append(s,o(i))}(e),t}},function(e,t,n){"use strict";var r=n(0),o=n(20),i=n(21),s=n(5),a=n(9),u=n(24),c=n(25),f=n(6),l=n(1),p=n(2),d=n(26);e.exports=function(e){return new Promise((function(t,n){var h,m=e.data,v=e.headers,y=e.responseType;function g(){e.cancelToken&&e.cancelToken.unsubscribe(h),e.signal&&e.signal.removeEventListener("abort",h)}r.isFormData(m)&&r.isStandardBrowserEnv()&&delete v["Content-Type"];var E=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",O=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(b+":"+O)}var x=a(e.baseURL,e.url);function w(){if(E){var r="getAllResponseHeaders"in E?u(E.getAllResponseHeaders()):null,i={data:y&&"text"!==y&&"json"!==y?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:r,config:e,request:E};o((function(e){t(e),g()}),(function(e){n(e),g()}),i),E=null}}if(E.open(e.method.toUpperCase(),s(x,e.params,e.paramsSerializer),!0),E.timeout=e.timeout,"onloadend"in E?E.onloadend=w:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(w)},E.onabort=function(){E&&(n(new l("Request aborted",l.ECONNABORTED,e,E)),E=null)},E.onerror=function(){n(new l("Network Error",l.ERR_NETWORK,e,E,E)),E=null},E.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||f;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new l(t,r.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,e,E)),E=null},r.isStandardBrowserEnv()){var R=(e.withCredentials||c(x))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;R&&(v[e.xsrfHeaderName]=R)}"setRequestHeader"in E&&r.forEach(v,(function(e,t){void 0===m&&"content-type"===t.toLowerCase()?delete v[t]:E.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(E.withCredentials=!!e.withCredentials),y&&"json"!==y&&(E.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&E.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&E.upload&&E.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(h=function(e){E&&(n(!e||e&&e.type?new p:e),E.abort(),E=null)},e.cancelToken&&e.cancelToken.subscribe(h),e.signal&&(e.signal.aborted?h():e.signal.addEventListener("abort",h))),m||(m=null);var S=d(x);S&&-1===["http","https","file"].indexOf(S)?n(new l("Unsupported protocol "+S+":",l.ERR_BAD_REQUEST,e)):E.send(m)}))}},function(e,t,n){"use strict";var r=n(22),o=n(23);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||{};var n={};function o(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return o(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(void 0,t[n])}function u(n){return n in t?o(e[n],t[n]):n in e?o(void 0,e[n]):void 0}var c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,o=t(e);r.isUndefined(o)&&t!==u||(n[e]=o)})),n}},function(e,t){e.exports={version:"0.27.2"}},function(e,t,n){e.exports=n(14)},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(15),s=n(11);var a=function e(t){var n=new i(t),a=o(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(3));a.Axios=i,a.CanceledError=n(2),a.CancelToken=n(29),a.isCancel=n(10),a.VERSION=n(12).version,a.toFormData=n(7),a.AxiosError=n(1),a.Cancel=a.CanceledError,a.all=function(e){return Promise.all(e)},a.spread=n(30),a.isAxiosError=n(31),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";var r=n(0),o=n(5),i=n(16),s=n(17),a=n(11),u=n(9),c=n(28),f=c.validators;function l(e){this.defaults=e,this.interceptors={request:new i,response:new i}}l.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&c.assertOptions(n,{silentJSONParsing:f.transitional(f.boolean),forcedJSONParsing:f.transitional(f.boolean),clarifyTimeoutError:f.transitional(f.boolean)},!1);var r=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var i,u=[];if(this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)})),!o){var l=[s,void 0];for(Array.prototype.unshift.apply(l,r),l=l.concat(u),i=Promise.resolve(t);l.length;)i=i.then(l.shift(),l.shift());return i}for(var p=t;r.length;){var d=r.shift(),h=r.shift();try{p=d(p)}catch(e){h(e);break}}try{i=s(p)}catch(e){return Promise.reject(e)}for(;u.length;)i=i.then(u.shift(),u.shift());return i},l.prototype.getUri=function(e){e=a(this.defaults,e);var t=u(e.baseURL,e.url);return o(t,e.params,e.paramsSerializer)},r.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(a(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}l.prototype[e]=t(),l.prototype[e+"Form"]=t(!0)})),e.exports=l},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(18),i=n(10),s=n(3),a=n(2);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return u(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var r=n(0),o=n(3);e.exports=function(e,t,n){var i=this||o;return r.forEach(n,(function(n){e=n.call(i,e,t)})),e}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},function(e,t,n){"use strict";var r=n(1);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new r("Request failed with status code "+n.status,[r.ERR_BAD_REQUEST,r.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,n){"use strict";var r=n(12).version,o=n(1),i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var s={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,a){if(!1===e)throw new o(i(r," has been removed"+(t?" in "+t:"")),o.ERR_DEPRECATED);return t&&!s[r]&&(s[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,a)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new o("options must be an object",o.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var s=r[i],a=t[s];if(a){var u=e[s],c=void 0===u||a(u,s,e);if(!0!==c)throw new o("option "+s+" must be "+c,o.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new o("Unknown option "+s,o.ERR_BAD_OPTION)}},validators:i}},function(e,t,n){"use strict";var r=n(2);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}}])})); | ||
//# sourceMappingURL=axios.min.map |
449
index.d.ts
@@ -1,112 +0,18 @@ | ||
// TypeScript Version: 4.7 | ||
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null; | ||
// TypeScript Version: 3.0 | ||
export type AxiosRequestHeaders = Record<string, string | number | boolean>; | ||
interface RawAxiosHeaders { | ||
[key: string]: AxiosHeaderValue; | ||
} | ||
type MethodsHeaders = Partial<{ | ||
[Key in Method as Lowercase<Key>]: AxiosHeaders; | ||
} & {common: AxiosHeaders}>; | ||
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean; | ||
export class AxiosHeaders { | ||
constructor( | ||
headers?: RawAxiosHeaders | AxiosHeaders | ||
); | ||
[key: string]: any; | ||
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders; | ||
get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue; | ||
has(header: string, matcher?: true | AxiosHeaderMatcher): boolean; | ||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; | ||
clear(matcher?: AxiosHeaderMatcher): boolean; | ||
normalize(format: boolean): AxiosHeaders; | ||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
toJSON(asStrings?: boolean): RawAxiosHeaders; | ||
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; | ||
static accessor(header: string | string[]): AxiosHeaders; | ||
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getContentType(parser?: RegExp): RegExpExecArray | null; | ||
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasContentType(matcher?: AxiosHeaderMatcher): boolean; | ||
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getContentLength(parser?: RegExp): RegExpExecArray | null; | ||
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasContentLength(matcher?: AxiosHeaderMatcher): boolean; | ||
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getAccept(parser?: RegExp): RegExpExecArray | null; | ||
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasAccept(matcher?: AxiosHeaderMatcher): boolean; | ||
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getUserAgent(parser?: RegExp): RegExpExecArray | null; | ||
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean; | ||
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getContentEncoding(parser?: RegExp): RegExpExecArray | null; | ||
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean; | ||
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getAuthorization(parser?: RegExp): RegExpExecArray | null; | ||
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean; | ||
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>; | ||
} | ||
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization'; | ||
type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream'; | ||
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & { | ||
[Key in CommonRequestHeadersList]: AxiosHeaderValue; | ||
} & { | ||
'Content-Type': ContentType | ||
}>; | ||
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders; | ||
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding'; | ||
type RawCommonResponseHeaders = { | ||
[Key in CommonResponseHeadersList]: AxiosHeaderValue; | ||
} & { | ||
"set-cookie": string[]; | ||
export type AxiosResponseHeaders = Record<string, string> & { | ||
"set-cookie"?: string[] | ||
}; | ||
export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>; | ||
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders; | ||
export interface AxiosRequestTransformer { | ||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any; | ||
(data: any, headers?: AxiosRequestHeaders): any; | ||
} | ||
export interface AxiosResponseTransformer { | ||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any; | ||
(data: any, headers?: AxiosResponseHeaders): any; | ||
} | ||
export interface AxiosAdapter { | ||
(config: InternalAxiosRequestConfig): AxiosPromise; | ||
(config: AxiosRequestConfig): AxiosPromise; | ||
} | ||
@@ -129,101 +35,35 @@ | ||
export enum HttpStatusCode { | ||
Continue = 100, | ||
SwitchingProtocols = 101, | ||
Processing = 102, | ||
EarlyHints = 103, | ||
Ok = 200, | ||
Created = 201, | ||
Accepted = 202, | ||
NonAuthoritativeInformation = 203, | ||
NoContent = 204, | ||
ResetContent = 205, | ||
PartialContent = 206, | ||
MultiStatus = 207, | ||
AlreadyReported = 208, | ||
ImUsed = 226, | ||
MultipleChoices = 300, | ||
MovedPermanently = 301, | ||
Found = 302, | ||
SeeOther = 303, | ||
NotModified = 304, | ||
UseProxy = 305, | ||
Unused = 306, | ||
TemporaryRedirect = 307, | ||
PermanentRedirect = 308, | ||
BadRequest = 400, | ||
Unauthorized = 401, | ||
PaymentRequired = 402, | ||
Forbidden = 403, | ||
NotFound = 404, | ||
MethodNotAllowed = 405, | ||
NotAcceptable = 406, | ||
ProxyAuthenticationRequired = 407, | ||
RequestTimeout = 408, | ||
Conflict = 409, | ||
Gone = 410, | ||
LengthRequired = 411, | ||
PreconditionFailed = 412, | ||
PayloadTooLarge = 413, | ||
UriTooLong = 414, | ||
UnsupportedMediaType = 415, | ||
RangeNotSatisfiable = 416, | ||
ExpectationFailed = 417, | ||
ImATeapot = 418, | ||
MisdirectedRequest = 421, | ||
UnprocessableEntity = 422, | ||
Locked = 423, | ||
FailedDependency = 424, | ||
TooEarly = 425, | ||
UpgradeRequired = 426, | ||
PreconditionRequired = 428, | ||
TooManyRequests = 429, | ||
RequestHeaderFieldsTooLarge = 431, | ||
UnavailableForLegalReasons = 451, | ||
InternalServerError = 500, | ||
NotImplemented = 501, | ||
BadGateway = 502, | ||
ServiceUnavailable = 503, | ||
GatewayTimeout = 504, | ||
HttpVersionNotSupported = 505, | ||
VariantAlsoNegotiates = 506, | ||
InsufficientStorage = 507, | ||
LoopDetected = 508, | ||
NotExtended = 510, | ||
NetworkAuthenticationRequired = 511, | ||
} | ||
export type Method = | ||
| 'get' | 'GET' | ||
| 'delete' | 'DELETE' | ||
| 'head' | 'HEAD' | ||
| 'options' | 'OPTIONS' | ||
| 'post' | 'POST' | ||
| 'put' | 'PUT' | ||
| 'patch' | 'PATCH' | ||
| 'purge' | 'PURGE' | ||
| 'link' | 'LINK' | ||
| 'unlink' | 'UNLINK'; | ||
| 'get' | 'GET' | ||
| 'delete' | 'DELETE' | ||
| 'head' | 'HEAD' | ||
| 'options' | 'OPTIONS' | ||
| 'post' | 'POST' | ||
| 'put' | 'PUT' | ||
| 'patch' | 'PATCH' | ||
| 'purge' | 'PURGE' | ||
| 'link' | 'LINK' | ||
| 'unlink' | 'UNLINK'; | ||
export type ResponseType = | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream'; | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream'; | ||
export type responseEncoding = | ||
| 'ascii' | 'ASCII' | ||
| 'ansi' | 'ANSI' | ||
| 'binary' | 'BINARY' | ||
| 'base64' | 'BASE64' | ||
| 'base64url' | 'BASE64URL' | ||
| 'hex' | 'HEX' | ||
| 'latin1' | 'LATIN1' | ||
| 'ucs-2' | 'UCS-2' | ||
| 'ucs2' | 'UCS2' | ||
| 'utf-8' | 'UTF-8' | ||
| 'utf8' | 'UTF8' | ||
| 'utf16le' | 'UTF16LE'; | ||
export type responseEncoding = | ||
| 'ascii' | 'ASCII' | ||
| 'ansi' | 'ANSI' | ||
| 'binary' | 'BINARY' | ||
| 'base64' | 'BASE64' | ||
| 'base64url' | 'BASE64URL' | ||
| 'hex' | 'HEX' | ||
| 'latin1' | 'LATIN1' | ||
| 'ucs-2' | 'UCS-2' | ||
| 'ucs2' | 'UCS2' | ||
| 'utf-8' | 'UTF-8' | ||
| 'utf8' | 'UTF8' | ||
| 'utf16le' | 'UTF16LE'; | ||
@@ -236,73 +76,2 @@ export interface TransitionalOptions { | ||
export interface GenericAbortSignal { | ||
readonly aborted: boolean; | ||
onabort?: ((...args: any) => any) | null; | ||
addEventListener?: (...args: any) => any; | ||
removeEventListener?: (...args: any) => any; | ||
} | ||
export interface FormDataVisitorHelpers { | ||
defaultVisitor: SerializerVisitor; | ||
convertValue: (value: any) => any; | ||
isVisitable: (value: any) => boolean; | ||
} | ||
export interface SerializerVisitor { | ||
( | ||
this: GenericFormData, | ||
value: any, | ||
key: string | number, | ||
path: null | Array<string | number>, | ||
helpers: FormDataVisitorHelpers | ||
): boolean; | ||
} | ||
export interface SerializerOptions { | ||
visitor?: SerializerVisitor; | ||
dots?: boolean; | ||
metaTokens?: boolean; | ||
indexes?: boolean | null; | ||
} | ||
// tslint:disable-next-line | ||
export interface FormSerializerOptions extends SerializerOptions { | ||
} | ||
export interface ParamEncoder { | ||
(value: any, defaultEncoder: (value: any) => any): any; | ||
} | ||
export interface CustomParamsSerializer { | ||
(params: Record<string, any>, options?: ParamsSerializerOptions): string; | ||
} | ||
export interface ParamsSerializerOptions extends SerializerOptions { | ||
encode?: ParamEncoder; | ||
serialize?: CustomParamsSerializer; | ||
} | ||
type MaxUploadRate = number; | ||
type MaxDownloadRate = number; | ||
type BrowserProgressEvent = any; | ||
export interface AxiosProgressEvent { | ||
loaded: number; | ||
total?: number; | ||
progress?: number; | ||
bytes: number; | ||
rate?: number; | ||
estimated?: number; | ||
upload?: boolean; | ||
download?: boolean; | ||
event?: BrowserProgressEvent; | ||
} | ||
type Milliseconds = number; | ||
type AxiosAdapterName = 'xhr' | 'http' | string; | ||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName; | ||
export interface AxiosRequestConfig<D = any> { | ||
@@ -314,10 +83,10 @@ url?: string; | ||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; | ||
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders; | ||
headers?: AxiosRequestHeaders; | ||
params?: any; | ||
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer; | ||
paramsSerializer?: (params: any) => string; | ||
data?: D; | ||
timeout?: Milliseconds; | ||
timeout?: number; | ||
timeoutErrorMessage?: string; | ||
withCredentials?: boolean; | ||
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[]; | ||
adapter?: AxiosAdapter; | ||
auth?: AxiosBasicCredentials; | ||
@@ -328,4 +97,4 @@ responseType?: ResponseType; | ||
xsrfHeaderName?: string; | ||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
onUploadProgress?: (progressEvent: any) => void; | ||
onDownloadProgress?: (progressEvent: any) => void; | ||
maxContentLength?: number; | ||
@@ -335,6 +104,4 @@ validateStatus?: ((status: number) => boolean) | null; | ||
maxRedirects?: number; | ||
maxRate?: number | [MaxUploadRate, MaxDownloadRate]; | ||
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void; | ||
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void; | ||
socketPath?: string | null; | ||
transport?: any; | ||
httpAgent?: any; | ||
@@ -346,3 +113,3 @@ httpsAgent?: any; | ||
transitional?: TransitionalOptions; | ||
signal?: GenericAbortSignal; | ||
signal?: AbortSignal; | ||
insecureHTTPParser?: boolean; | ||
@@ -352,27 +119,16 @@ env?: { | ||
}; | ||
formSerializer?: FormSerializerOptions; | ||
family?: 4 | 6 | undefined; | ||
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: string, family: number) => void) => void) | | ||
((hostname: string, options: object) => Promise<[address: string, family: number] | string>); | ||
} | ||
// Alias | ||
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>; | ||
export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> { | ||
headers: AxiosRequestHeaders; | ||
} | ||
export interface HeadersDefaults { | ||
common: RawAxiosRequestHeaders; | ||
delete: RawAxiosRequestHeaders; | ||
get: RawAxiosRequestHeaders; | ||
head: RawAxiosRequestHeaders; | ||
post: RawAxiosRequestHeaders; | ||
put: RawAxiosRequestHeaders; | ||
patch: RawAxiosRequestHeaders; | ||
options?: RawAxiosRequestHeaders; | ||
purge?: RawAxiosRequestHeaders; | ||
link?: RawAxiosRequestHeaders; | ||
unlink?: RawAxiosRequestHeaders; | ||
common: AxiosRequestHeaders; | ||
delete: AxiosRequestHeaders; | ||
get: AxiosRequestHeaders; | ||
head: AxiosRequestHeaders; | ||
post: AxiosRequestHeaders; | ||
put: AxiosRequestHeaders; | ||
patch: AxiosRequestHeaders; | ||
options?: AxiosRequestHeaders; | ||
purge?: AxiosRequestHeaders; | ||
link?: AxiosRequestHeaders; | ||
unlink?: AxiosRequestHeaders; | ||
} | ||
@@ -384,12 +140,8 @@ | ||
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> { | ||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>; | ||
} | ||
export interface AxiosResponse<T = any, D = any> { | ||
export interface AxiosResponse<T = any, D = any> { | ||
data: T; | ||
status: number; | ||
statusText: string; | ||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders; | ||
config: InternalAxiosRequestConfig<D>; | ||
headers: AxiosResponseHeaders; | ||
config: AxiosRequestConfig<D>; | ||
request?: any; | ||
@@ -400,10 +152,10 @@ } | ||
constructor( | ||
message?: string, | ||
code?: string, | ||
config?: InternalAxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
message?: string, | ||
code?: string, | ||
config?: AxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
); | ||
config?: InternalAxiosRequestConfig<D>; | ||
config: AxiosRequestConfig<D>; | ||
code?: string; | ||
@@ -413,13 +165,4 @@ request?: any; | ||
isAxiosError: boolean; | ||
status?: number; | ||
status?: string; | ||
toJSON: () => object; | ||
cause?: Error; | ||
static from<T = unknown, D = any>( | ||
error: Error | unknown, | ||
code?: string, | ||
config?: InternalAxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D>, | ||
customProps?: object, | ||
): AxiosError<T, D>; | ||
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS"; | ||
@@ -432,4 +175,2 @@ static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE"; | ||
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST"; | ||
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT"; | ||
static readonly ERR_INVALID_URL = "ERR_INVALID_URL"; | ||
static readonly ERR_CANCELED = "ERR_CANCELED"; | ||
@@ -443,3 +184,4 @@ static readonly ECONNABORTED = "ECONNABORTED"; | ||
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>; | ||
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> { | ||
} | ||
@@ -455,3 +197,3 @@ export interface CancelStatic { | ||
export interface Canceler { | ||
(message?: string, config?: AxiosRequestConfig, request?: any): void; | ||
(message?: string): void; | ||
} | ||
@@ -477,9 +219,8 @@ | ||
synchronous?: boolean; | ||
runWhen?: (config: InternalAxiosRequestConfig) => boolean; | ||
runWhen?: (config: AxiosRequestConfig) => boolean; | ||
} | ||
export interface AxiosInterceptorManager<V> { | ||
use(onFulfilled?: ((value: V) => V | Promise<V>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions): number; | ||
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number; | ||
eject(id: number): void; | ||
clear(): void; | ||
} | ||
@@ -491,3 +232,3 @@ | ||
interceptors: { | ||
request: AxiosInterceptorManager<InternalAxiosRequestConfig>; | ||
request: AxiosInterceptorManager<AxiosRequestConfig>; | ||
response: AxiosInterceptorManager<AxiosResponse>; | ||
@@ -510,50 +251,16 @@ }; | ||
export interface AxiosInstance extends Axios { | ||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>; | ||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
defaults: Omit<AxiosDefaults, 'headers'> & { | ||
headers: HeadersDefaults & { | ||
[key: string]: AxiosHeaderValue | ||
} | ||
}; | ||
(config: AxiosRequestConfig): AxiosPromise; | ||
(url: string, config?: AxiosRequestConfig): AxiosPromise; | ||
} | ||
export interface GenericFormData { | ||
append(name: string, value: any, options?: any): any; | ||
} | ||
export interface GenericHTMLFormElement { | ||
name: string; | ||
method: string; | ||
submit(): void; | ||
} | ||
export function toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData; | ||
export function formToJSON(form: GenericFormData|GenericHTMLFormElement): object; | ||
export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>; | ||
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R; | ||
export function isCancel(value: any): value is Cancel; | ||
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>; | ||
export interface AxiosStatic extends AxiosInstance { | ||
create(config?: CreateAxiosDefaults): AxiosInstance; | ||
create(config?: AxiosRequestConfig): AxiosInstance; | ||
Cancel: CancelStatic; | ||
CancelToken: CancelTokenStatic; | ||
Axios: typeof Axios; | ||
AxiosError: typeof AxiosError; | ||
HttpStatusCode: typeof HttpStatusCode; | ||
readonly VERSION: string; | ||
isCancel: typeof isCancel; | ||
all: typeof all; | ||
spread: typeof spread; | ||
isAxiosError: typeof isAxiosError; | ||
toFormData: typeof toFormData; | ||
formToJSON: typeof formToJSON; | ||
CanceledError: typeof CanceledError; | ||
AxiosHeaders: typeof AxiosHeaders; | ||
isCancel(value: any): boolean; | ||
all<T>(values: Array<T | Promise<T>>): Promise<T[]>; | ||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R; | ||
isAxiosError(payload: any): payload is AxiosError; | ||
} | ||
@@ -560,0 +267,0 @@ |
42
index.js
@@ -1,41 +0,1 @@ | ||
import axios from './lib/axios.js'; | ||
// This module is intended to unwrap Axios default export as named. | ||
// Keep top-level export same with static properties | ||
// so that it can keep same with es module or cjs | ||
const { | ||
Axios, | ||
AxiosError, | ||
CanceledError, | ||
isCancel, | ||
CancelToken, | ||
VERSION, | ||
all, | ||
Cancel, | ||
isAxiosError, | ||
spread, | ||
toFormData, | ||
AxiosHeaders, | ||
HttpStatusCode, | ||
formToJSON, | ||
mergeConfig | ||
} = axios; | ||
export { | ||
axios as default, | ||
Axios, | ||
AxiosError, | ||
CanceledError, | ||
isCancel, | ||
CancelToken, | ||
VERSION, | ||
all, | ||
Cancel, | ||
isAxiosError, | ||
spread, | ||
toFormData, | ||
AxiosHeaders, | ||
HttpStatusCode, | ||
formToJSON, | ||
mergeConfig | ||
} | ||
module.exports = require('./lib/axios'); |
'use strict'; | ||
import utils from './../utils.js'; | ||
import settle from './../core/settle.js'; | ||
import buildFullPath from '../core/buildFullPath.js'; | ||
import buildURL from './../helpers/buildURL.js'; | ||
import {getProxyForUrl} from 'proxy-from-env'; | ||
import http from 'http'; | ||
import https from 'https'; | ||
import util from 'util'; | ||
import followRedirects from 'follow-redirects'; | ||
import zlib from 'zlib'; | ||
import {VERSION} from '../env/data.js'; | ||
import transitionalDefaults from '../defaults/transitional.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import platform from '../platform/index.js'; | ||
import fromDataURI from '../helpers/fromDataURI.js'; | ||
import stream from 'stream'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import AxiosTransformStream from '../helpers/AxiosTransformStream.js'; | ||
import EventEmitter from 'events'; | ||
import formDataToStream from "../helpers/formDataToStream.js"; | ||
import readBlob from "../helpers/readBlob.js"; | ||
import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js'; | ||
import callbackify from "../helpers/callbackify.js"; | ||
var utils = require('./../utils'); | ||
var settle = require('./../core/settle'); | ||
var buildFullPath = require('../core/buildFullPath'); | ||
var buildURL = require('./../helpers/buildURL'); | ||
var http = require('http'); | ||
var https = require('https'); | ||
var httpFollow = require('follow-redirects').http; | ||
var httpsFollow = require('follow-redirects').https; | ||
var url = require('url'); | ||
var zlib = require('zlib'); | ||
var VERSION = require('./../env/data').version; | ||
var transitionalDefaults = require('../defaults/transitional'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
const zlibOptions = { | ||
flush: zlib.constants.Z_SYNC_FLUSH, | ||
finishFlush: zlib.constants.Z_SYNC_FLUSH | ||
}; | ||
var isHttps = /https:?/; | ||
const brotliOptions = { | ||
flush: zlib.constants.BROTLI_OPERATION_FLUSH, | ||
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH | ||
} | ||
var supportedProtocols = [ 'http:', 'https:', 'file:' ]; | ||
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress); | ||
const {http: httpFollow, https: httpsFollow} = followRedirects; | ||
const isHttps = /https:?/; | ||
const supportedProtocols = platform.protocols.map(protocol => { | ||
return protocol + ':'; | ||
}); | ||
/** | ||
* If the proxy or config beforeRedirects functions are defined, call them with the options | ||
* object. | ||
* | ||
* @param {Object<string, any>} options - The options object that was passed to the request. | ||
* | ||
* @returns {Object<string, any>} | ||
*/ | ||
function dispatchBeforeRedirect(options) { | ||
if (options.beforeRedirects.proxy) { | ||
options.beforeRedirects.proxy(options); | ||
} | ||
if (options.beforeRedirects.config) { | ||
options.beforeRedirects.config(options); | ||
} | ||
} | ||
/** | ||
* If the proxy or config afterRedirects functions are defined, call them with the options | ||
* | ||
* @param {http.ClientRequestArgs} options | ||
* @param {AxiosProxyConfig} configProxy configuration from Axios options object | ||
* @param {AxiosProxyConfig} proxy | ||
* @param {string} location | ||
* | ||
* @returns {http.ClientRequestArgs} | ||
*/ | ||
function setProxy(options, configProxy, location) { | ||
let proxy = configProxy; | ||
if (!proxy && proxy !== false) { | ||
const proxyUrl = getProxyForUrl(location); | ||
if (proxyUrl) { | ||
proxy = new URL(proxyUrl); | ||
} | ||
} | ||
if (proxy) { | ||
// Basic proxy authorization | ||
if (proxy.username) { | ||
proxy.auth = (proxy.username || '') + ':' + (proxy.password || ''); | ||
} | ||
function setProxy(options, proxy, location) { | ||
options.hostname = proxy.host; | ||
options.host = proxy.host; | ||
options.port = proxy.port; | ||
options.path = location; | ||
if (proxy.auth) { | ||
// Support proxy auth object form | ||
if (proxy.auth.username || proxy.auth.password) { | ||
proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || ''); | ||
} | ||
const base64 = Buffer | ||
.from(proxy.auth, 'utf8') | ||
.toString('base64'); | ||
options.headers['Proxy-Authorization'] = 'Basic ' + base64; | ||
} | ||
options.headers.host = options.hostname + (options.port ? ':' + options.port : ''); | ||
const proxyHost = proxy.hostname || proxy.host; | ||
options.hostname = proxyHost; | ||
// Replace 'host' since options is not a URL object | ||
options.host = proxyHost; | ||
options.port = proxy.port; | ||
options.path = location; | ||
if (proxy.protocol) { | ||
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`; | ||
} | ||
// Basic proxy authorization | ||
if (proxy.auth) { | ||
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); | ||
options.headers['Proxy-Authorization'] = 'Basic ' + base64; | ||
} | ||
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) { | ||
// Configure proxy for redirected request, passing the original config proxy to apply | ||
// the exact same logic as if the redirected request was performed by axios directly. | ||
setProxy(redirectOptions, configProxy, redirectOptions.href); | ||
// If a proxy is used, any redirects must also pass through the proxy | ||
options.beforeRedirect = function beforeRedirect(redirection) { | ||
redirection.headers.host = redirection.host; | ||
setProxy(redirection, proxy, redirection.href); | ||
}; | ||
} | ||
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process'; | ||
// temporary hotfix | ||
const wrapAsync = (asyncExecutor) => { | ||
return new Promise((resolve, reject) => { | ||
let onDone; | ||
let isDone; | ||
const done = (value, isRejected) => { | ||
if (isDone) return; | ||
isDone = true; | ||
onDone && onDone(value, isRejected); | ||
} | ||
const _resolve = (value) => { | ||
done(value); | ||
resolve(value); | ||
}; | ||
const _reject = (reason) => { | ||
done(reason, true); | ||
reject(reason); | ||
} | ||
asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject); | ||
}) | ||
}; | ||
/*eslint consistent-return:0*/ | ||
export default isHttpAdapterSupported && function httpAdapter(config) { | ||
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) { | ||
let {data, lookup, family} = config; | ||
const {responseType, responseEncoding} = config; | ||
const method = config.method.toUpperCase(); | ||
let isDone; | ||
let rejected = false; | ||
let req; | ||
if (lookup && utils.isAsyncFn(lookup)) { | ||
lookup = callbackify(lookup, (entry) => { | ||
if(utils.isString(entry)) { | ||
entry = [entry, entry.indexOf('.') < 0 ? 6 : 4] | ||
} else if (!utils.isArray(entry)) { | ||
throw new TypeError('lookup async function must return an array [ip: string, family: number]]') | ||
} | ||
return entry; | ||
}) | ||
} | ||
// temporary internal emitter until the AxiosRequest class will be implemented | ||
const emitter = new EventEmitter(); | ||
const onFinished = () => { | ||
module.exports = function httpAdapter(config) { | ||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { | ||
var onCanceled; | ||
function done() { | ||
if (config.cancelToken) { | ||
config.cancelToken.unsubscribe(abort); | ||
config.cancelToken.unsubscribe(onCanceled); | ||
} | ||
if (config.signal) { | ||
config.signal.removeEventListener('abort', abort); | ||
config.signal.removeEventListener('abort', onCanceled); | ||
} | ||
emitter.removeAllListeners(); | ||
} | ||
var resolve = function resolve(value) { | ||
done(); | ||
resolvePromise(value); | ||
}; | ||
var rejected = false; | ||
var reject = function reject(value) { | ||
done(); | ||
rejected = true; | ||
rejectPromise(value); | ||
}; | ||
var data = config.data; | ||
var headers = config.headers; | ||
var headerNames = {}; | ||
onDone((value, isRejected) => { | ||
isDone = true; | ||
if (isRejected) { | ||
rejected = true; | ||
onFinished(); | ||
} | ||
Object.keys(headers).forEach(function storeLowerName(name) { | ||
headerNames[name.toLowerCase()] = name; | ||
}); | ||
function abort(reason) { | ||
emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason); | ||
} | ||
emitter.once('abort', reject); | ||
if (config.cancelToken || config.signal) { | ||
config.cancelToken && config.cancelToken.subscribe(abort); | ||
if (config.signal) { | ||
config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort); | ||
// Set User-Agent (required by some servers) | ||
// See https://github.com/axios/axios/issues/69 | ||
if ('user-agent' in headerNames) { | ||
// User-Agent is specified; handle case where no UA header is desired | ||
if (!headers[headerNames['user-agent']]) { | ||
delete headers[headerNames['user-agent']]; | ||
} | ||
// Otherwise, use specified value | ||
} else { | ||
// Only set header if it hasn't been set in config | ||
headers['User-Agent'] = 'axios/' + VERSION; | ||
} | ||
// Parse url | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
const parsed = new URL(fullPath, 'http://localhost'); | ||
const protocol = parsed.protocol || supportedProtocols[0]; | ||
if (protocol === 'data:') { | ||
let convertedData; | ||
if (method !== 'GET') { | ||
return settle(resolve, reject, { | ||
status: 405, | ||
statusText: 'method not allowed', | ||
headers: {}, | ||
config | ||
}); | ||
} | ||
try { | ||
convertedData = fromDataURI(config.url, responseType === 'blob', { | ||
Blob: config.env && config.env.Blob | ||
}); | ||
} catch (err) { | ||
throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config); | ||
} | ||
if (responseType === 'text') { | ||
convertedData = convertedData.toString(responseEncoding); | ||
if (!responseEncoding || responseEncoding === 'utf8') { | ||
convertedData = utils.stripBOM(convertedData); | ||
} | ||
} else if (responseType === 'stream') { | ||
convertedData = stream.Readable.from(convertedData); | ||
} | ||
return settle(resolve, reject, { | ||
data: convertedData, | ||
status: 200, | ||
statusText: 'OK', | ||
headers: new AxiosHeaders(), | ||
config | ||
}); | ||
} | ||
if (supportedProtocols.indexOf(protocol) === -1) { | ||
return reject(new AxiosError( | ||
'Unsupported protocol ' + protocol, | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
const headers = AxiosHeaders.from(config.headers).normalize(); | ||
// Set User-Agent (required by some servers) | ||
// See https://github.com/axios/axios/issues/69 | ||
// User-Agent is specified; handle case where no UA header is desired | ||
// Only set header if it hasn't been set in config | ||
headers.set('User-Agent', 'axios/' + VERSION, false); | ||
const onDownloadProgress = config.onDownloadProgress; | ||
const onUploadProgress = config.onUploadProgress; | ||
const maxRate = config.maxRate; | ||
let maxUploadRate = undefined; | ||
let maxDownloadRate = undefined; | ||
// support for spec compliant FormData objects | ||
if (utils.isSpecCompliantForm(data)) { | ||
const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i); | ||
data = formDataToStream(data, (formHeaders) => { | ||
headers.set(formHeaders); | ||
}, { | ||
tag: `axios-${VERSION}-boundary`, | ||
boundary: userBoundary && userBoundary[1] || undefined | ||
}); | ||
// support for https://www.npmjs.com/package/form-data api | ||
} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) { | ||
headers.set(data.getHeaders()); | ||
if (!headers.hasContentLength()) { | ||
try { | ||
const knownLength = await util.promisify(data.getLength).call(data); | ||
Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength); | ||
/*eslint no-empty:0*/ | ||
} catch (e) { | ||
} | ||
} | ||
} else if (utils.isBlob(data)) { | ||
data.size && headers.setContentType(data.type || 'application/octet-stream'); | ||
headers.setContentLength(data.size || 0); | ||
data = stream.Readable.from(readBlob(data)); | ||
// support for https://www.npmjs.com/package/form-data api | ||
if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) { | ||
Object.assign(headers, data.getHeaders()); | ||
} else if (data && !utils.isStream(data)) { | ||
@@ -311,5 +109,2 @@ if (Buffer.isBuffer(data)) { | ||
// Add Content-Length header if data exists | ||
headers.setContentLength(data.length, false); | ||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) { | ||
@@ -322,78 +117,61 @@ return reject(new AxiosError( | ||
} | ||
} | ||
const contentLength = utils.toFiniteNumber(headers.getContentLength()); | ||
if (utils.isArray(maxRate)) { | ||
maxUploadRate = maxRate[0]; | ||
maxDownloadRate = maxRate[1]; | ||
} else { | ||
maxUploadRate = maxDownloadRate = maxRate; | ||
} | ||
if (data && (onUploadProgress || maxUploadRate)) { | ||
if (!utils.isStream(data)) { | ||
data = stream.Readable.from(data, {objectMode: false}); | ||
// Add Content-Length header if data exists | ||
if (!headerNames['content-length']) { | ||
headers['Content-Length'] = data.length; | ||
} | ||
data = stream.pipeline([data, new AxiosTransformStream({ | ||
length: contentLength, | ||
maxRate: utils.toFiniteNumber(maxUploadRate) | ||
})], utils.noop); | ||
onUploadProgress && data.on('progress', progress => { | ||
onUploadProgress(Object.assign(progress, { | ||
upload: true | ||
})); | ||
}); | ||
} | ||
// HTTP basic authentication | ||
let auth = undefined; | ||
var auth = undefined; | ||
if (config.auth) { | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password || ''; | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password || ''; | ||
auth = username + ':' + password; | ||
} | ||
if (!auth && parsed.username) { | ||
const urlUsername = parsed.username; | ||
const urlPassword = parsed.password; | ||
// Parse url | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
var parsed = url.parse(fullPath); | ||
var protocol = parsed.protocol || supportedProtocols[0]; | ||
if (supportedProtocols.indexOf(protocol) === -1) { | ||
return reject(new AxiosError( | ||
'Unsupported protocol ' + protocol, | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
if (!auth && parsed.auth) { | ||
var urlAuth = parsed.auth.split(':'); | ||
var urlUsername = urlAuth[0] || ''; | ||
var urlPassword = urlAuth[1] || ''; | ||
auth = urlUsername + ':' + urlPassword; | ||
} | ||
auth && headers.delete('authorization'); | ||
if (auth && headerNames.authorization) { | ||
delete headers[headerNames.authorization]; | ||
} | ||
let path; | ||
var isHttpsRequest = isHttps.test(protocol); | ||
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
try { | ||
path = buildURL( | ||
parsed.pathname + parsed.search, | ||
config.params, | ||
config.paramsSerializer | ||
).replace(/^\?/, ''); | ||
buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
} catch (err) { | ||
const customErr = new Error(err.message); | ||
var customErr = new Error(err.message); | ||
customErr.config = config; | ||
customErr.url = config.url; | ||
customErr.exists = true; | ||
return reject(customErr); | ||
reject(customErr); | ||
} | ||
headers.set( | ||
'Accept-Encoding', | ||
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false | ||
); | ||
const options = { | ||
path, | ||
method: method, | ||
headers: headers.toJSON(), | ||
var options = { | ||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), | ||
method: config.method.toUpperCase(), | ||
headers: headers, | ||
agent: agent, | ||
agents: { http: config.httpAgent, https: config.httpsAgent }, | ||
auth, | ||
protocol, | ||
family, | ||
lookup, | ||
beforeRedirect: dispatchBeforeRedirect, | ||
beforeRedirects: {} | ||
auth: auth | ||
}; | ||
@@ -406,12 +184,63 @@ | ||
options.port = parsed.port; | ||
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path); | ||
} | ||
let transport; | ||
const isHttpsRequest = isHttps.test(options.protocol); | ||
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
var proxy = config.proxy; | ||
if (!proxy && proxy !== false) { | ||
var proxyEnv = protocol.slice(0, -1) + '_proxy'; | ||
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; | ||
if (proxyUrl) { | ||
var parsedProxyUrl = url.parse(proxyUrl); | ||
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY; | ||
var shouldProxy = true; | ||
if (noProxyEnv) { | ||
var noProxy = noProxyEnv.split(',').map(function trim(s) { | ||
return s.trim(); | ||
}); | ||
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) { | ||
if (!proxyElement) { | ||
return false; | ||
} | ||
if (proxyElement === '*') { | ||
return true; | ||
} | ||
if (proxyElement[0] === '.' && | ||
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) { | ||
return true; | ||
} | ||
return parsed.hostname === proxyElement; | ||
}); | ||
} | ||
if (shouldProxy) { | ||
proxy = { | ||
host: parsedProxyUrl.hostname, | ||
port: parsedProxyUrl.port, | ||
protocol: parsedProxyUrl.protocol | ||
}; | ||
if (parsedProxyUrl.auth) { | ||
var proxyUrlAuth = parsedProxyUrl.auth.split(':'); | ||
proxy.auth = { | ||
username: proxyUrlAuth[0], | ||
password: proxyUrlAuth[1] | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
if (proxy) { | ||
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : ''); | ||
setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path); | ||
} | ||
var transport; | ||
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true); | ||
if (config.transport) { | ||
transport = config.transport; | ||
} else if (config.maxRedirects === 0) { | ||
transport = isHttpsRequest ? https : http; | ||
transport = isHttpsProxy ? https : http; | ||
} else { | ||
@@ -422,5 +251,5 @@ if (config.maxRedirects) { | ||
if (config.beforeRedirect) { | ||
options.beforeRedirects.config = config.beforeRedirect; | ||
options.beforeRedirect = config.beforeRedirect; | ||
} | ||
transport = isHttpsRequest ? httpsFollow : httpFollow; | ||
transport = isHttpsProxy ? httpsFollow : httpFollow; | ||
} | ||
@@ -430,5 +259,2 @@ | ||
options.maxBodyLength = config.maxBodyLength; | ||
} else { | ||
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited | ||
options.maxBodyLength = Infinity; | ||
} | ||
@@ -441,90 +267,43 @@ | ||
// Create the request | ||
req = transport.request(options, function handleResponse(res) { | ||
if (req.destroyed) return; | ||
var req = transport.request(options, function handleResponse(res) { | ||
if (req.aborted) return; | ||
const streams = [res]; | ||
// uncompress the response body transparently if required | ||
var stream = res; | ||
const responseLength = +res.headers['content-length']; | ||
if (onDownloadProgress) { | ||
const transformStream = new AxiosTransformStream({ | ||
length: utils.toFiniteNumber(responseLength), | ||
maxRate: utils.toFiniteNumber(maxDownloadRate) | ||
}); | ||
onDownloadProgress && transformStream.on('progress', progress => { | ||
onDownloadProgress(Object.assign(progress, { | ||
download: true | ||
})); | ||
}); | ||
streams.push(transformStream); | ||
} | ||
// decompress the response body transparently if required | ||
let responseStream = res; | ||
// return the last request in case of redirects | ||
const lastRequest = res.req || req; | ||
var lastRequest = res.req || req; | ||
// if decompress disabled we should not decompress | ||
if (config.decompress !== false && res.headers['content-encoding']) { | ||
// if no content, but headers still say that it is encoded, | ||
// remove the header not confuse downstream operations | ||
if (method === 'HEAD' || res.statusCode === 204) { | ||
delete res.headers['content-encoding']; | ||
} | ||
// if no content, is HEAD request or decompress disabled we should not decompress | ||
if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) { | ||
switch (res.headers['content-encoding']) { | ||
/*eslint default-case:0*/ | ||
case 'gzip': | ||
case 'x-gzip': | ||
case 'compress': | ||
case 'x-compress': | ||
// add the unzipper to the body stream processing pipeline | ||
streams.push(zlib.createUnzip(zlibOptions)); | ||
// remove the content-encoding in order to not confuse downstream operations | ||
delete res.headers['content-encoding']; | ||
break; | ||
case 'deflate': | ||
streams.push(new ZlibHeaderTransformStream()); | ||
// add the unzipper to the body stream processing pipeline | ||
stream = stream.pipe(zlib.createUnzip()); | ||
// add the unzipper to the body stream processing pipeline | ||
streams.push(zlib.createUnzip(zlibOptions)); | ||
// remove the content-encoding in order to not confuse downstream operations | ||
delete res.headers['content-encoding']; | ||
break; | ||
case 'br': | ||
if (isBrotliSupported) { | ||
streams.push(zlib.createBrotliDecompress(brotliOptions)); | ||
delete res.headers['content-encoding']; | ||
} | ||
} | ||
} | ||
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0]; | ||
const offListeners = stream.finished(responseStream, () => { | ||
offListeners(); | ||
onFinished(); | ||
}); | ||
const response = { | ||
var response = { | ||
status: res.statusCode, | ||
statusText: res.statusMessage, | ||
headers: new AxiosHeaders(res.headers), | ||
config, | ||
headers: res.headers, | ||
config: config, | ||
request: lastRequest | ||
}; | ||
if (responseType === 'stream') { | ||
response.data = responseStream; | ||
if (config.responseType === 'stream') { | ||
response.data = stream; | ||
settle(resolve, reject, response); | ||
} else { | ||
const responseBuffer = []; | ||
let totalResponseBytes = 0; | ||
responseStream.on('data', function handleStreamData(chunk) { | ||
var responseBuffer = []; | ||
var totalResponseBytes = 0; | ||
stream.on('data', function handleStreamData(chunk) { | ||
responseBuffer.push(chunk); | ||
@@ -535,5 +314,5 @@ totalResponseBytes += chunk.length; | ||
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) { | ||
// stream.destroy() emit aborted event before calling reject() on Node.js v16 | ||
// stream.destoy() emit aborted event before calling reject() on Node.js v16 | ||
rejected = true; | ||
responseStream.destroy(); | ||
stream.destroy(); | ||
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
@@ -544,8 +323,8 @@ AxiosError.ERR_BAD_RESPONSE, config, lastRequest)); | ||
responseStream.on('aborted', function handlerStreamAborted() { | ||
stream.on('aborted', function handlerStreamAborted() { | ||
if (rejected) { | ||
return; | ||
} | ||
const err = new AxiosError( | ||
stream.destroy(); | ||
reject(new AxiosError( | ||
'maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
@@ -555,18 +334,16 @@ AxiosError.ERR_BAD_RESPONSE, | ||
lastRequest | ||
); | ||
responseStream.destroy(err); | ||
reject(err); | ||
)); | ||
}); | ||
responseStream.on('error', function handleStreamError(err) { | ||
if (req.destroyed) return; | ||
stream.on('error', function handleStreamError(err) { | ||
if (req.aborted) return; | ||
reject(AxiosError.from(err, null, config, lastRequest)); | ||
}); | ||
responseStream.on('end', function handleStreamEnd() { | ||
stream.on('end', function handleStreamEnd() { | ||
try { | ||
let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer); | ||
if (responseType !== 'arraybuffer') { | ||
responseData = responseData.toString(responseEncoding); | ||
if (!responseEncoding || responseEncoding === 'utf8') { | ||
var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer); | ||
if (config.responseType !== 'arraybuffer') { | ||
responseData = responseData.toString(config.responseEncoding); | ||
if (!config.responseEncoding || config.responseEncoding === 'utf8') { | ||
responseData = utils.stripBOM(responseData); | ||
@@ -582,16 +359,4 @@ } | ||
} | ||
emitter.once('abort', err => { | ||
if (!responseStream.destroyed) { | ||
responseStream.emit('error', err); | ||
responseStream.destroy(); | ||
} | ||
}); | ||
}); | ||
emitter.once('abort', err => { | ||
reject(err); | ||
req.destroy(err); | ||
}); | ||
// Handle errors | ||
@@ -613,3 +378,3 @@ req.on('error', function handleRequestError(err) { | ||
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types. | ||
const timeout = parseInt(config.timeout, 10); | ||
var timeout = parseInt(config.timeout, 10); | ||
@@ -630,13 +395,9 @@ if (isNaN(timeout)) { | ||
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up. | ||
// And then these socket which be hang up will devouring CPU little by little. | ||
// And then these socket which be hang up will devoring CPU little by little. | ||
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect. | ||
req.setTimeout(timeout, function handleRequestTimeout() { | ||
if (isDone) return; | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
timeoutErrorMessage = config.timeoutErrorMessage; | ||
} | ||
req.abort(); | ||
var transitional = config.transitional || transitionalDefaults; | ||
reject(new AxiosError( | ||
timeoutErrorMessage, | ||
'timeout of ' + timeout + 'ms exceeded', | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
@@ -646,28 +407,27 @@ config, | ||
)); | ||
abort(); | ||
}); | ||
} | ||
if (config.cancelToken || config.signal) { | ||
// Handle cancellation | ||
// eslint-disable-next-line func-names | ||
onCanceled = function(cancel) { | ||
if (req.aborted) return; | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
let ended = false; | ||
let errored = false; | ||
req.abort(); | ||
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel); | ||
}; | ||
data.on('end', () => { | ||
ended = true; | ||
}); | ||
config.cancelToken && config.cancelToken.subscribe(onCanceled); | ||
if (config.signal) { | ||
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); | ||
} | ||
} | ||
data.once('error', err => { | ||
errored = true; | ||
req.destroy(err); | ||
}); | ||
data.on('close', () => { | ||
if (!ended && !errored) { | ||
abort(new CanceledError('Request stream has been aborted', config, req)); | ||
} | ||
}); | ||
data.pipe(req); | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
data.on('error', function handleStreamError(err) { | ||
reject(AxiosError.from(err, config, null, req)); | ||
}).pipe(req); | ||
} else { | ||
@@ -677,4 +437,2 @@ req.end(data); | ||
}); | ||
} | ||
export const __setProxy = setProxy; | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
import settle from './../core/settle.js'; | ||
import cookies from './../helpers/cookies.js'; | ||
import buildURL from './../helpers/buildURL.js'; | ||
import buildFullPath from '../core/buildFullPath.js'; | ||
import isURLSameOrigin from './../helpers/isURLSameOrigin.js'; | ||
import transitionalDefaults from '../defaults/transitional.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import parseProtocol from '../helpers/parseProtocol.js'; | ||
import platform from '../platform/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import speedometer from '../helpers/speedometer.js'; | ||
var utils = require('./../utils'); | ||
var settle = require('./../core/settle'); | ||
var cookies = require('./../helpers/cookies'); | ||
var buildURL = require('./../helpers/buildURL'); | ||
var buildFullPath = require('../core/buildFullPath'); | ||
var parseHeaders = require('./../helpers/parseHeaders'); | ||
var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); | ||
var transitionalDefaults = require('../defaults/transitional'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
var parseProtocol = require('../helpers/parseProtocol'); | ||
function progressEventReducer(listener, isDownloadStream) { | ||
let bytesNotified = 0; | ||
const _speedometer = speedometer(50, 250); | ||
return e => { | ||
const loaded = e.loaded; | ||
const total = e.lengthComputable ? e.total : undefined; | ||
const progressBytes = loaded - bytesNotified; | ||
const rate = _speedometer(progressBytes); | ||
const inRange = loaded <= total; | ||
bytesNotified = loaded; | ||
const data = { | ||
loaded, | ||
total, | ||
progress: total ? (loaded / total) : undefined, | ||
bytes: progressBytes, | ||
rate: rate ? rate : undefined, | ||
estimated: rate && total && inRange ? (total - loaded) / rate : undefined, | ||
event: e | ||
}; | ||
data[isDownloadStream ? 'download' : 'upload'] = true; | ||
listener(data); | ||
}; | ||
} | ||
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined'; | ||
export default isXHRAdapterSupported && function (config) { | ||
module.exports = function xhrAdapter(config) { | ||
return new Promise(function dispatchXhrRequest(resolve, reject) { | ||
let requestData = config.data; | ||
const requestHeaders = AxiosHeaders.from(config.headers).normalize(); | ||
const responseType = config.responseType; | ||
let onCanceled; | ||
var requestData = config.data; | ||
var requestHeaders = config.headers; | ||
var responseType = config.responseType; | ||
var onCanceled; | ||
function done() { | ||
@@ -64,20 +31,16 @@ if (config.cancelToken) { | ||
if (utils.isFormData(requestData)) { | ||
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) { | ||
requestHeaders.setContentType(false); // Let the browser set it | ||
} else { | ||
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks | ||
} | ||
if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) { | ||
delete requestHeaders['Content-Type']; // Let the browser set it | ||
} | ||
let request = new XMLHttpRequest(); | ||
var request = new XMLHttpRequest(); | ||
// HTTP basic authentication | ||
if (config.auth) { | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password)); | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); | ||
} | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
@@ -94,8 +57,6 @@ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); | ||
// Prepare the response | ||
const responseHeaders = AxiosHeaders.from( | ||
'getAllResponseHeaders' in request && request.getAllResponseHeaders() | ||
); | ||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; | ||
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
request.responseText : request.response; | ||
const response = { | ||
var response = { | ||
data: responseData, | ||
@@ -105,4 +66,4 @@ status: request.status, | ||
headers: responseHeaders, | ||
config, | ||
request | ||
config: config, | ||
request: request | ||
}; | ||
@@ -161,3 +122,3 @@ | ||
// onerror should only fire if it's a network error | ||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request)); | ||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request)); | ||
@@ -170,4 +131,4 @@ // Clean up request | ||
request.ontimeout = function handleTimeout() { | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
var transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
@@ -189,19 +150,23 @@ timeoutErrorMessage = config.timeoutErrorMessage; | ||
// Specifically not if we're in a web worker, or react-native. | ||
if (platform.isStandardBrowserEnv) { | ||
if (utils.isStandardBrowserEnv()) { | ||
// Add xsrf header | ||
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) | ||
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName); | ||
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? | ||
cookies.read(config.xsrfCookieName) : | ||
undefined; | ||
if (xsrfValue) { | ||
requestHeaders.set(config.xsrfHeaderName, xsrfValue); | ||
requestHeaders[config.xsrfHeaderName] = xsrfValue; | ||
} | ||
} | ||
// Remove Content-Type if data is undefined | ||
requestData === undefined && requestHeaders.setContentType(null); | ||
// Add headers to the request | ||
if ('setRequestHeader' in request) { | ||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { | ||
request.setRequestHeader(key, val); | ||
utils.forEach(requestHeaders, function setRequestHeader(val, key) { | ||
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { | ||
// Remove Content-Type if data is undefined | ||
delete requestHeaders[key]; | ||
} else { | ||
// Otherwise add header to the request | ||
request.setRequestHeader(key, val); | ||
} | ||
}); | ||
@@ -222,3 +187,3 @@ } | ||
if (typeof config.onDownloadProgress === 'function') { | ||
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true)); | ||
request.addEventListener('progress', config.onDownloadProgress); | ||
} | ||
@@ -228,3 +193,3 @@ | ||
if (typeof config.onUploadProgress === 'function' && request.upload) { | ||
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress)); | ||
request.upload.addEventListener('progress', config.onUploadProgress); | ||
} | ||
@@ -235,7 +200,7 @@ | ||
// eslint-disable-next-line func-names | ||
onCanceled = cancel => { | ||
onCanceled = function(cancel) { | ||
if (!request) { | ||
return; | ||
} | ||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel); | ||
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel); | ||
request.abort(); | ||
@@ -251,5 +216,9 @@ request = null; | ||
const protocol = parseProtocol(fullPath); | ||
if (!requestData) { | ||
requestData = null; | ||
} | ||
if (protocol && platform.protocols.indexOf(protocol) === -1) { | ||
var protocol = parseProtocol(fullPath); | ||
if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) { | ||
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config)); | ||
@@ -261,4 +230,4 @@ return; | ||
// Send the request | ||
request.send(requestData || null); | ||
request.send(requestData); | ||
}); | ||
} | ||
}; |
'use strict'; | ||
import utils from './utils.js'; | ||
import bind from './helpers/bind.js'; | ||
import Axios from './core/Axios.js'; | ||
import mergeConfig from './core/mergeConfig.js'; | ||
import defaults from './defaults/index.js'; | ||
import formDataToJSON from './helpers/formDataToJSON.js'; | ||
import CanceledError from './cancel/CanceledError.js'; | ||
import CancelToken from './cancel/CancelToken.js'; | ||
import isCancel from './cancel/isCancel.js'; | ||
import {VERSION} from './env/data.js'; | ||
import toFormData from './helpers/toFormData.js'; | ||
import AxiosError from './core/AxiosError.js'; | ||
import spread from './helpers/spread.js'; | ||
import isAxiosError from './helpers/isAxiosError.js'; | ||
import AxiosHeaders from "./core/AxiosHeaders.js"; | ||
import HttpStatusCode from './helpers/HttpStatusCode.js'; | ||
var utils = require('./utils'); | ||
var bind = require('./helpers/bind'); | ||
var Axios = require('./core/Axios'); | ||
var mergeConfig = require('./core/mergeConfig'); | ||
var defaults = require('./defaults'); | ||
@@ -24,14 +13,13 @@ /** | ||
* @param {Object} defaultConfig The default config for the instance | ||
* | ||
* @returns {Axios} A new instance of Axios | ||
* @return {Axios} A new instance of Axios | ||
*/ | ||
function createInstance(defaultConfig) { | ||
const context = new Axios(defaultConfig); | ||
const instance = bind(Axios.prototype.request, context); | ||
var context = new Axios(defaultConfig); | ||
var instance = bind(Axios.prototype.request, context); | ||
// Copy axios.prototype to instance | ||
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true}); | ||
utils.extend(instance, Axios.prototype, context); | ||
// Copy context to instance | ||
utils.extend(instance, context, null, {allOwnKeys: true}); | ||
utils.extend(instance, context); | ||
@@ -47,3 +35,3 @@ // Factory for creating new instances | ||
// Create the default instance to be exported | ||
const axios = createInstance(defaults); | ||
var axios = createInstance(defaults); | ||
@@ -54,10 +42,10 @@ // Expose Axios class to allow class inheritance | ||
// Expose Cancel & CancelToken | ||
axios.CanceledError = CanceledError; | ||
axios.CancelToken = CancelToken; | ||
axios.isCancel = isCancel; | ||
axios.VERSION = VERSION; | ||
axios.toFormData = toFormData; | ||
axios.CanceledError = require('./cancel/CanceledError'); | ||
axios.CancelToken = require('./cancel/CancelToken'); | ||
axios.isCancel = require('./cancel/isCancel'); | ||
axios.VERSION = require('./env/data').version; | ||
axios.toFormData = require('./helpers/toFormData'); | ||
// Expose AxiosError class | ||
axios.AxiosError = AxiosError; | ||
axios.AxiosError = require('../lib/core/AxiosError'); | ||
@@ -71,20 +59,10 @@ // alias for CanceledError for backward compatibility | ||
}; | ||
axios.spread = require('./helpers/spread'); | ||
axios.spread = spread; | ||
// Expose isAxiosError | ||
axios.isAxiosError = isAxiosError; | ||
axios.isAxiosError = require('./helpers/isAxiosError'); | ||
// Expose mergeConfig | ||
axios.mergeConfig = mergeConfig; | ||
module.exports = axios; | ||
axios.AxiosHeaders = AxiosHeaders; | ||
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing); | ||
axios.HttpStatusCode = HttpStatusCode; | ||
axios.default = axios; | ||
// this module should only have a default export | ||
export default axios | ||
// Allow use of default import syntax in TypeScript | ||
module.exports.default = axios; |
'use strict'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import utils from '../utils.js'; | ||
var AxiosError = require('../core/AxiosError'); | ||
var utils = require('../utils'); | ||
@@ -9,11 +9,8 @@ /** | ||
* | ||
* @class | ||
* @param {string=} message The message. | ||
* @param {Object=} config The config. | ||
* @param {Object=} request The request. | ||
* | ||
* @returns {CanceledError} The created error. | ||
*/ | ||
function CanceledError(message, config, request) { | ||
function CanceledError(message) { | ||
// eslint-disable-next-line no-eq-null,eqeqeq | ||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request); | ||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED); | ||
this.name = 'CanceledError'; | ||
@@ -26,2 +23,2 @@ } | ||
export default CanceledError; | ||
module.exports = CanceledError; |
'use strict'; | ||
import CanceledError from './CanceledError.js'; | ||
var CanceledError = require('./CanceledError'); | ||
@@ -8,115 +8,113 @@ /** | ||
* | ||
* @class | ||
* @param {Function} executor The executor function. | ||
* | ||
* @returns {CancelToken} | ||
*/ | ||
class CancelToken { | ||
constructor(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
function CancelToken(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
let resolvePromise; | ||
var resolvePromise; | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
const token = this; | ||
var token = this; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(cancel => { | ||
if (!token._listeners) return; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(function(cancel) { | ||
if (!token._listeners) return; | ||
let i = token._listeners.length; | ||
var i; | ||
var l = token._listeners.length; | ||
while (i-- > 0) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
for (i = 0; i < l; i++) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
// eslint-disable-next-line func-names | ||
this.promise.then = function(onfulfilled) { | ||
var _resolve; | ||
// eslint-disable-next-line func-names | ||
this.promise.then = onfulfilled => { | ||
let _resolve; | ||
// eslint-disable-next-line func-names | ||
const promise = new Promise(resolve => { | ||
token.subscribe(resolve); | ||
_resolve = resolve; | ||
}).then(onfulfilled); | ||
var promise = new Promise(function(resolve) { | ||
token.subscribe(resolve); | ||
_resolve = resolve; | ||
}).then(onfulfilled); | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
}; | ||
return promise; | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
}; | ||
executor(function cancel(message, config, request) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
} | ||
return promise; | ||
}; | ||
token.reason = new CanceledError(message, config, request); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
executor(function cancel(message) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
} | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
token.reason = new CanceledError(message); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
CancelToken.prototype.throwIfRequested = function throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
}; | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
CancelToken.prototype.subscribe = function subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
} | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
} | ||
}; | ||
/** | ||
* Unsubscribe from the cancel signal | ||
*/ | ||
/** | ||
* Unsubscribe from the cancel signal | ||
*/ | ||
unsubscribe(listener) { | ||
if (!this._listeners) { | ||
return; | ||
} | ||
const index = this._listeners.indexOf(listener); | ||
if (index !== -1) { | ||
this._listeners.splice(index, 1); | ||
} | ||
CancelToken.prototype.unsubscribe = function unsubscribe(listener) { | ||
if (!this._listeners) { | ||
return; | ||
} | ||
/** | ||
* Returns an object that contains a new `CancelToken` and a function that, when called, | ||
* cancels the `CancelToken`. | ||
*/ | ||
static source() { | ||
let cancel; | ||
const token = new CancelToken(function executor(c) { | ||
cancel = c; | ||
}); | ||
return { | ||
token, | ||
cancel | ||
}; | ||
var index = this._listeners.indexOf(listener); | ||
if (index !== -1) { | ||
this._listeners.splice(index, 1); | ||
} | ||
} | ||
}; | ||
export default CancelToken; | ||
/** | ||
* Returns an object that contains a new `CancelToken` and a function that, when called, | ||
* cancels the `CancelToken`. | ||
*/ | ||
CancelToken.source = function source() { | ||
var cancel; | ||
var token = new CancelToken(function executor(c) { | ||
cancel = c; | ||
}); | ||
return { | ||
token: token, | ||
cancel: cancel | ||
}; | ||
}; | ||
module.exports = CancelToken; |
'use strict'; | ||
export default function isCancel(value) { | ||
module.exports = function isCancel(value) { | ||
return !!(value && value.__CANCEL__); | ||
} | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
import buildURL from '../helpers/buildURL.js'; | ||
import InterceptorManager from './InterceptorManager.js'; | ||
import dispatchRequest from './dispatchRequest.js'; | ||
import mergeConfig from './mergeConfig.js'; | ||
import buildFullPath from './buildFullPath.js'; | ||
import validator from '../helpers/validator.js'; | ||
import AxiosHeaders from './AxiosHeaders.js'; | ||
var utils = require('./../utils'); | ||
var buildURL = require('../helpers/buildURL'); | ||
var InterceptorManager = require('./InterceptorManager'); | ||
var dispatchRequest = require('./dispatchRequest'); | ||
var mergeConfig = require('./mergeConfig'); | ||
var buildFullPath = require('./buildFullPath'); | ||
var validator = require('../helpers/validator'); | ||
const validators = validator.validators; | ||
var validators = validator.validators; | ||
/** | ||
@@ -18,154 +16,113 @@ * Create a new instance of Axios | ||
* @param {Object} instanceConfig The default config for the instance | ||
*/ | ||
function Axios(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
} | ||
/** | ||
* Dispatch a request | ||
* | ||
* @return {Axios} A new instance of Axios | ||
* @param {Object} config The config specific for this request (merged with this.defaults) | ||
*/ | ||
class Axios { | ||
constructor(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
Axios.prototype.request = function request(configOrUrl, config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof configOrUrl === 'string') { | ||
config = config || {}; | ||
config.url = configOrUrl; | ||
} else { | ||
config = configOrUrl || {}; | ||
} | ||
/** | ||
* Dispatch a request | ||
* | ||
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) | ||
* @param {?Object} config | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
request(configOrUrl, config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof configOrUrl === 'string') { | ||
config = config || {}; | ||
config.url = configOrUrl; | ||
} else { | ||
config = configOrUrl || {}; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
config = mergeConfig(this.defaults, config); | ||
// Set config.method | ||
if (config.method) { | ||
config.method = config.method.toLowerCase(); | ||
} else if (this.defaults.method) { | ||
config.method = this.defaults.method.toLowerCase(); | ||
} else { | ||
config.method = 'get'; | ||
} | ||
const {transitional, paramsSerializer, headers} = config; | ||
var transitional = config.transitional; | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
if (paramsSerializer != null) { | ||
if (utils.isFunction(paramsSerializer)) { | ||
config.paramsSerializer = { | ||
serialize: paramsSerializer | ||
} | ||
} else { | ||
validator.assertOptions(paramsSerializer, { | ||
encode: validators.function, | ||
serialize: validators.function | ||
}, true); | ||
} | ||
// filter out skipped interceptors | ||
var requestInterceptorChain = []; | ||
var synchronousRequestInterceptors = true; | ||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | ||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { | ||
return; | ||
} | ||
// Set config.method | ||
config.method = (config.method || this.defaults.method || 'get').toLowerCase(); | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
let contextHeaders; | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
// Flatten headers | ||
contextHeaders = headers && utils.merge( | ||
headers.common, | ||
headers[config.method] | ||
); | ||
var responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
contextHeaders && utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
(method) => { | ||
delete headers[method]; | ||
} | ||
); | ||
var promise; | ||
config.headers = AxiosHeaders.concat(contextHeaders, headers); | ||
if (!synchronousRequestInterceptors) { | ||
var chain = [dispatchRequest, undefined]; | ||
// filter out skipped interceptors | ||
const requestInterceptorChain = []; | ||
let synchronousRequestInterceptors = true; | ||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | ||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { | ||
return; | ||
} | ||
Array.prototype.unshift.apply(chain, requestInterceptorChain); | ||
chain = chain.concat(responseInterceptorChain); | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
const responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
let promise; | ||
let i = 0; | ||
let len; | ||
if (!synchronousRequestInterceptors) { | ||
const chain = [dispatchRequest.bind(this), undefined]; | ||
chain.unshift.apply(chain, requestInterceptorChain); | ||
chain.push.apply(chain, responseInterceptorChain); | ||
len = chain.length; | ||
promise = Promise.resolve(config); | ||
while (i < len) { | ||
promise = promise.then(chain[i++], chain[i++]); | ||
} | ||
return promise; | ||
promise = Promise.resolve(config); | ||
while (chain.length) { | ||
promise = promise.then(chain.shift(), chain.shift()); | ||
} | ||
len = requestInterceptorChain.length; | ||
return promise; | ||
} | ||
let newConfig = config; | ||
i = 0; | ||
while (i < len) { | ||
const onFulfilled = requestInterceptorChain[i++]; | ||
const onRejected = requestInterceptorChain[i++]; | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
} catch (error) { | ||
onRejected.call(this, error); | ||
break; | ||
} | ||
} | ||
var newConfig = config; | ||
while (requestInterceptorChain.length) { | ||
var onFulfilled = requestInterceptorChain.shift(); | ||
var onRejected = requestInterceptorChain.shift(); | ||
try { | ||
promise = dispatchRequest.call(this, newConfig); | ||
newConfig = onFulfilled(newConfig); | ||
} catch (error) { | ||
return Promise.reject(error); | ||
onRejected(error); | ||
break; | ||
} | ||
} | ||
i = 0; | ||
len = responseInterceptorChain.length; | ||
while (i < len) { | ||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]); | ||
} | ||
return promise; | ||
try { | ||
promise = dispatchRequest(newConfig); | ||
} catch (error) { | ||
return Promise.reject(error); | ||
} | ||
getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
while (responseInterceptorChain.length) { | ||
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); | ||
} | ||
} | ||
return promise; | ||
}; | ||
Axios.prototype.getUri = function getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
}; | ||
// Provide aliases for supported request methods | ||
@@ -176,4 +133,4 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { | ||
return this.request(mergeConfig(config || {}, { | ||
method, | ||
url, | ||
method: method, | ||
url: url, | ||
data: (config || {}).data | ||
@@ -190,8 +147,8 @@ })); | ||
return this.request(mergeConfig(config || {}, { | ||
method, | ||
method: method, | ||
headers: isForm ? { | ||
'Content-Type': 'multipart/form-data' | ||
} : {}, | ||
url, | ||
data | ||
url: url, | ||
data: data | ||
})); | ||
@@ -206,2 +163,2 @@ }; | ||
export default Axios; | ||
module.exports = Axios; |
'use strict'; | ||
import utils from '../utils.js'; | ||
var utils = require('../utils'); | ||
@@ -13,3 +13,2 @@ /** | ||
* @param {Object} [response] The response. | ||
* | ||
* @returns {Error} The created error. | ||
@@ -19,9 +18,2 @@ */ | ||
Error.call(this); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, this.constructor); | ||
} else { | ||
this.stack = (new Error()).stack; | ||
} | ||
this.message = message; | ||
@@ -50,3 +42,3 @@ this.name = 'AxiosError'; | ||
// Axios | ||
config: utils.toJSONObject(this.config), | ||
config: this.config, | ||
code: this.code, | ||
@@ -58,4 +50,4 @@ status: this.response && this.response.status ? this.response.status : null | ||
const prototype = AxiosError.prototype; | ||
const descriptors = {}; | ||
var prototype = AxiosError.prototype; | ||
var descriptors = {}; | ||
@@ -72,7 +64,5 @@ [ | ||
'ERR_BAD_REQUEST', | ||
'ERR_CANCELED', | ||
'ERR_NOT_SUPPORT', | ||
'ERR_INVALID_URL' | ||
'ERR_CANCELED' | ||
// eslint-disable-next-line func-names | ||
].forEach(code => { | ||
].forEach(function(code) { | ||
descriptors[code] = {value: code}; | ||
@@ -85,9 +75,7 @@ }); | ||
// eslint-disable-next-line func-names | ||
AxiosError.from = (error, code, config, request, response, customProps) => { | ||
const axiosError = Object.create(prototype); | ||
AxiosError.from = function(error, code, config, request, response, customProps) { | ||
var axiosError = Object.create(prototype); | ||
utils.toFlatObject(error, axiosError, function filter(obj) { | ||
return obj !== Error.prototype; | ||
}, prop => { | ||
return prop !== 'isAxiosError'; | ||
}); | ||
@@ -97,4 +85,2 @@ | ||
axiosError.cause = error; | ||
axiosError.name = error.name; | ||
@@ -107,2 +93,2 @@ | ||
export default AxiosError; | ||
module.exports = AxiosError; |
'use strict'; | ||
import isAbsoluteURL from '../helpers/isAbsoluteURL.js'; | ||
import combineURLs from '../helpers/combineURLs.js'; | ||
var isAbsoluteURL = require('../helpers/isAbsoluteURL'); | ||
var combineURLs = require('../helpers/combineURLs'); | ||
@@ -13,6 +13,5 @@ /** | ||
* @param {string} requestedURL Absolute or relative URL to combine | ||
* | ||
* @returns {string} The combined full path | ||
*/ | ||
export default function buildFullPath(baseURL, requestedURL) { | ||
module.exports = function buildFullPath(baseURL, requestedURL) { | ||
if (baseURL && !isAbsoluteURL(requestedURL)) { | ||
@@ -22,2 +21,2 @@ return combineURLs(baseURL, requestedURL); | ||
return requestedURL; | ||
} | ||
}; |
'use strict'; | ||
import transformData from './transformData.js'; | ||
import isCancel from '../cancel/isCancel.js'; | ||
import defaults from '../defaults/index.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import adapters from "../adapters/adapters.js"; | ||
var utils = require('./../utils'); | ||
var transformData = require('./transformData'); | ||
var isCancel = require('../cancel/isCancel'); | ||
var defaults = require('../defaults'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
* | ||
* @param {Object} config The config that is to be used for the request | ||
* | ||
* @returns {void} | ||
*/ | ||
@@ -23,3 +18,3 @@ function throwIfCancellationRequested(config) { | ||
if (config.signal && config.signal.aborted) { | ||
throw new CanceledError(null, config); | ||
throw new CanceledError(); | ||
} | ||
@@ -32,9 +27,9 @@ } | ||
* @param {object} config The config that is to be used for the request | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
export default function dispatchRequest(config) { | ||
module.exports = function dispatchRequest(config) { | ||
throwIfCancellationRequested(config); | ||
config.headers = AxiosHeaders.from(config.headers); | ||
// Ensure headers exist | ||
config.headers = config.headers || {}; | ||
@@ -44,11 +39,23 @@ // Transform request data | ||
config, | ||
config.data, | ||
config.headers, | ||
config.transformRequest | ||
); | ||
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) { | ||
config.headers.setContentType('application/x-www-form-urlencoded', false); | ||
} | ||
// Flatten headers | ||
config.headers = utils.merge( | ||
config.headers.common || {}, | ||
config.headers[config.method] || {}, | ||
config.headers | ||
); | ||
const adapter = adapters.getAdapter(config.adapter || defaults.adapter); | ||
utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
} | ||
); | ||
var adapter = config.adapter || defaults.adapter; | ||
return adapter(config).then(function onAdapterResolution(response) { | ||
@@ -60,8 +67,7 @@ throwIfCancellationRequested(config); | ||
config, | ||
config.transformResponse, | ||
response | ||
response.data, | ||
response.headers, | ||
config.transformResponse | ||
); | ||
response.headers = AxiosHeaders.from(response.headers); | ||
return response; | ||
@@ -76,6 +82,6 @@ }, function onAdapterRejection(reason) { | ||
config, | ||
config.transformResponse, | ||
reason.response | ||
reason.response.data, | ||
reason.response.headers, | ||
config.transformResponse | ||
); | ||
reason.response.headers = AxiosHeaders.from(reason.response.headers); | ||
} | ||
@@ -86,2 +92,2 @@ } | ||
}); | ||
} | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
var utils = require('./../utils'); | ||
class InterceptorManager { | ||
constructor() { | ||
this.handlers = []; | ||
} | ||
function InterceptorManager() { | ||
this.handlers = []; | ||
} | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
use(fulfilled, rejected, options) { | ||
this.handlers.push({ | ||
fulfilled, | ||
rejected, | ||
synchronous: options ? options.synchronous : false, | ||
runWhen: options ? options.runWhen : null | ||
}); | ||
return this.handlers.length - 1; | ||
} | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { | ||
this.handlers.push({ | ||
fulfilled: fulfilled, | ||
rejected: rejected, | ||
synchronous: options ? options.synchronous : false, | ||
runWhen: options ? options.runWhen : null | ||
}); | ||
return this.handlers.length - 1; | ||
}; | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
* | ||
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise | ||
*/ | ||
eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
} | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
*/ | ||
InterceptorManager.prototype.eject = function eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
} | ||
}; | ||
/** | ||
* Clear all interceptors from the stack | ||
* | ||
* @returns {void} | ||
*/ | ||
clear() { | ||
if (this.handlers) { | ||
this.handlers = []; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
*/ | ||
InterceptorManager.prototype.forEach = function forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
} | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
* | ||
* @returns {void} | ||
*/ | ||
forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
} | ||
}); | ||
} | ||
} | ||
export default InterceptorManager; | ||
module.exports = InterceptorManager; |
'use strict'; | ||
import utils from '../utils.js'; | ||
import AxiosHeaders from "./AxiosHeaders.js"; | ||
var utils = require('../utils'); | ||
const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing; | ||
/** | ||
@@ -14,13 +11,12 @@ * Config-specific merge-function which creates a new config-object | ||
* @param {Object} config2 | ||
* | ||
* @returns {Object} New object resulting from merging config2 to config1 | ||
*/ | ||
export default function mergeConfig(config1, config2) { | ||
module.exports = function mergeConfig(config1, config2) { | ||
// eslint-disable-next-line no-param-reassign | ||
config2 = config2 || {}; | ||
const config = {}; | ||
var config = {}; | ||
function getMergedValue(target, source, caseless) { | ||
function getMergedValue(target, source) { | ||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) { | ||
return utils.merge.call({caseless}, target, source); | ||
return utils.merge(target, source); | ||
} else if (utils.isPlainObject(source)) { | ||
@@ -35,7 +31,7 @@ return utils.merge({}, source); | ||
// eslint-disable-next-line consistent-return | ||
function mergeDeepProperties(a, b, caseless) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(a, b, caseless); | ||
} else if (!utils.isUndefined(a)) { | ||
return getMergedValue(undefined, a, caseless); | ||
function mergeDeepProperties(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
return getMergedValue(config1[prop], config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
return getMergedValue(undefined, config1[prop]); | ||
} | ||
@@ -45,5 +41,5 @@ } | ||
// eslint-disable-next-line consistent-return | ||
function valueFromConfig2(a, b) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(undefined, b); | ||
function valueFromConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
return getMergedValue(undefined, config2[prop]); | ||
} | ||
@@ -53,7 +49,7 @@ } | ||
// eslint-disable-next-line consistent-return | ||
function defaultToConfig2(a, b) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(undefined, b); | ||
} else if (!utils.isUndefined(a)) { | ||
return getMergedValue(undefined, a); | ||
function defaultToConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
return getMergedValue(undefined, config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
return getMergedValue(undefined, config1[prop]); | ||
} | ||
@@ -63,44 +59,43 @@ } | ||
// eslint-disable-next-line consistent-return | ||
function mergeDirectKeys(a, b, prop) { | ||
function mergeDirectKeys(prop) { | ||
if (prop in config2) { | ||
return getMergedValue(a, b); | ||
return getMergedValue(config1[prop], config2[prop]); | ||
} else if (prop in config1) { | ||
return getMergedValue(undefined, a); | ||
return getMergedValue(undefined, config1[prop]); | ||
} | ||
} | ||
const mergeMap = { | ||
url: valueFromConfig2, | ||
method: valueFromConfig2, | ||
data: valueFromConfig2, | ||
baseURL: defaultToConfig2, | ||
transformRequest: defaultToConfig2, | ||
transformResponse: defaultToConfig2, | ||
paramsSerializer: defaultToConfig2, | ||
timeout: defaultToConfig2, | ||
timeoutMessage: defaultToConfig2, | ||
withCredentials: defaultToConfig2, | ||
adapter: defaultToConfig2, | ||
responseType: defaultToConfig2, | ||
xsrfCookieName: defaultToConfig2, | ||
xsrfHeaderName: defaultToConfig2, | ||
onUploadProgress: defaultToConfig2, | ||
onDownloadProgress: defaultToConfig2, | ||
decompress: defaultToConfig2, | ||
maxContentLength: defaultToConfig2, | ||
maxBodyLength: defaultToConfig2, | ||
beforeRedirect: defaultToConfig2, | ||
transport: defaultToConfig2, | ||
httpAgent: defaultToConfig2, | ||
httpsAgent: defaultToConfig2, | ||
cancelToken: defaultToConfig2, | ||
socketPath: defaultToConfig2, | ||
responseEncoding: defaultToConfig2, | ||
validateStatus: mergeDirectKeys, | ||
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true) | ||
var mergeMap = { | ||
'url': valueFromConfig2, | ||
'method': valueFromConfig2, | ||
'data': valueFromConfig2, | ||
'baseURL': defaultToConfig2, | ||
'transformRequest': defaultToConfig2, | ||
'transformResponse': defaultToConfig2, | ||
'paramsSerializer': defaultToConfig2, | ||
'timeout': defaultToConfig2, | ||
'timeoutMessage': defaultToConfig2, | ||
'withCredentials': defaultToConfig2, | ||
'adapter': defaultToConfig2, | ||
'responseType': defaultToConfig2, | ||
'xsrfCookieName': defaultToConfig2, | ||
'xsrfHeaderName': defaultToConfig2, | ||
'onUploadProgress': defaultToConfig2, | ||
'onDownloadProgress': defaultToConfig2, | ||
'decompress': defaultToConfig2, | ||
'maxContentLength': defaultToConfig2, | ||
'maxBodyLength': defaultToConfig2, | ||
'beforeRedirect': defaultToConfig2, | ||
'transport': defaultToConfig2, | ||
'httpAgent': defaultToConfig2, | ||
'httpsAgent': defaultToConfig2, | ||
'cancelToken': defaultToConfig2, | ||
'socketPath': defaultToConfig2, | ||
'responseEncoding': defaultToConfig2, | ||
'validateStatus': mergeDirectKeys | ||
}; | ||
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) { | ||
const merge = mergeMap[prop] || mergeDeepProperties; | ||
const configValue = merge(config1[prop], config2[prop], prop); | ||
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { | ||
var merge = mergeMap[prop] || mergeDeepProperties; | ||
var configValue = merge(prop); | ||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); | ||
@@ -110,2 +105,2 @@ }); | ||
return config; | ||
} | ||
}; |
'use strict'; | ||
import AxiosError from './AxiosError.js'; | ||
var AxiosError = require('./AxiosError'); | ||
@@ -11,7 +11,5 @@ /** | ||
* @param {object} response The response. | ||
* | ||
* @returns {object} The response. | ||
*/ | ||
export default function settle(resolve, reject, response) { | ||
const validateStatus = response.config.validateStatus; | ||
module.exports = function settle(resolve, reject, response) { | ||
var validateStatus = response.config.validateStatus; | ||
if (!response.status || !validateStatus || validateStatus(response.status)) { | ||
@@ -28,2 +26,2 @@ resolve(response); | ||
} | ||
} | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
import defaults from '../defaults/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
var utils = require('./../utils'); | ||
var defaults = require('../defaults'); | ||
@@ -10,20 +9,15 @@ /** | ||
* | ||
* @param {Object|String} data The data to be transformed | ||
* @param {Array} headers The headers for the request or response | ||
* @param {Array|Function} fns A single function or Array of functions | ||
* @param {?Object} response The response object | ||
* | ||
* @returns {*} The resulting transformed data | ||
*/ | ||
export default function transformData(fns, response) { | ||
const config = this || defaults; | ||
const context = response || config; | ||
const headers = AxiosHeaders.from(context.headers); | ||
let data = context.data; | ||
module.exports = function transformData(data, headers, fns) { | ||
var context = this || defaults; | ||
/*eslint no-param-reassign:0*/ | ||
utils.forEach(fns, function transform(fn) { | ||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); | ||
data = fn.call(context, data, headers); | ||
}); | ||
headers.normalize(); | ||
return data; | ||
} | ||
}; |
'use strict'; | ||
import utils from '../utils.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import transitionalDefaults from './transitional.js'; | ||
import toFormData from '../helpers/toFormData.js'; | ||
import toURLEncodedForm from '../helpers/toURLEncodedForm.js'; | ||
import platform from '../platform/index.js'; | ||
import formDataToJSON from '../helpers/formDataToJSON.js'; | ||
var utils = require('../utils'); | ||
var normalizeHeaderName = require('../helpers/normalizeHeaderName'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var transitionalDefaults = require('./transitional'); | ||
var toFormData = require('../helpers/toFormData'); | ||
const DEFAULT_CONTENT_TYPE = { | ||
'Content-Type': undefined | ||
var DEFAULT_CONTENT_TYPE = { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
}; | ||
/** | ||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version | ||
* of the input | ||
* | ||
* @param {any} rawValue - The value to be stringified. | ||
* @param {Function} parser - A function that parses a string into a JavaScript object. | ||
* @param {Function} encoder - A function that takes a value and returns a string. | ||
* | ||
* @returns {string} A stringified version of the rawValue. | ||
*/ | ||
function setContentTypeIfUnset(headers, value) { | ||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { | ||
headers['Content-Type'] = value; | ||
} | ||
} | ||
function getDefaultAdapter() { | ||
var adapter; | ||
if (typeof XMLHttpRequest !== 'undefined') { | ||
// For browsers use XHR adapter | ||
adapter = require('../adapters/xhr'); | ||
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { | ||
// For node use HTTP adapter | ||
adapter = require('../adapters/http'); | ||
} | ||
return adapter; | ||
} | ||
function stringifySafely(rawValue, parser, encoder) { | ||
@@ -40,27 +46,14 @@ if (utils.isString(rawValue)) { | ||
const defaults = { | ||
var defaults = { | ||
transitional: transitionalDefaults, | ||
adapter: ['xhr', 'http'], | ||
adapter: getDefaultAdapter(), | ||
transformRequest: [function transformRequest(data, headers) { | ||
const contentType = headers.getContentType() || ''; | ||
const hasJSONContentType = contentType.indexOf('application/json') > -1; | ||
const isObjectPayload = utils.isObject(data); | ||
normalizeHeaderName(headers, 'Accept'); | ||
normalizeHeaderName(headers, 'Content-Type'); | ||
if (isObjectPayload && utils.isHTMLForm(data)) { | ||
data = new FormData(data); | ||
} | ||
const isFormData = utils.isFormData(data); | ||
if (isFormData) { | ||
if (!hasJSONContentType) { | ||
return data; | ||
} | ||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data; | ||
} | ||
if (utils.isArrayBuffer(data) || | ||
if (utils.isFormData(data) || | ||
utils.isArrayBuffer(data) || | ||
utils.isBuffer(data) || | ||
@@ -77,26 +70,16 @@ utils.isStream(data) || | ||
if (utils.isURLSearchParams(data)) { | ||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false); | ||
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); | ||
return data.toString(); | ||
} | ||
let isFileList; | ||
var isObjectPayload = utils.isObject(data); | ||
var contentType = headers && headers['Content-Type']; | ||
if (isObjectPayload) { | ||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) { | ||
return toURLEncodedForm(data, this.formSerializer).toString(); | ||
} | ||
var isFileList; | ||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) { | ||
const _FormData = this.env && this.env.FormData; | ||
return toFormData( | ||
isFileList ? {'files[]': data} : data, | ||
_FormData && new _FormData(), | ||
this.formSerializer | ||
); | ||
} | ||
} | ||
if (isObjectPayload || hasJSONContentType ) { | ||
headers.setContentType('application/json', false); | ||
if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) { | ||
var _FormData = this.env && this.env.FormData; | ||
return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData()); | ||
} else if (isObjectPayload || contentType === 'application/json') { | ||
setContentTypeIfUnset(headers, 'application/json'); | ||
return stringifySafely(data); | ||
@@ -109,10 +92,8 @@ } | ||
transformResponse: [function transformResponse(data) { | ||
const transitional = this.transitional || defaults.transitional; | ||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing; | ||
const JSONRequested = this.responseType === 'json'; | ||
var transitional = this.transitional || defaults.transitional; | ||
var silentJSONParsing = transitional && transitional.silentJSONParsing; | ||
var forcedJSONParsing = transitional && transitional.forcedJSONParsing; | ||
var strictJSONParsing = !silentJSONParsing && this.responseType === 'json'; | ||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) { | ||
const silentJSONParsing = transitional && transitional.silentJSONParsing; | ||
const strictJSONParsing = !silentJSONParsing && JSONRequested; | ||
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) { | ||
try { | ||
@@ -146,4 +127,3 @@ return JSON.parse(data); | ||
env: { | ||
FormData: platform.classes.FormData, | ||
Blob: platform.classes.Blob | ||
FormData: require('./env/FormData') | ||
}, | ||
@@ -170,2 +150,2 @@ | ||
export default defaults; | ||
module.exports = defaults; |
'use strict'; | ||
export default { | ||
module.exports = { | ||
silentJSONParsing: true, | ||
@@ -5,0 +5,0 @@ forcedJSONParsing: true, |
@@ -1,1 +0,3 @@ | ||
export const VERSION = "1.4.0"; | ||
module.exports = { | ||
"version": "0.27.2" | ||
}; |
'use strict'; | ||
export default function bind(fn, thisArg) { | ||
module.exports = function bind(fn, thisArg) { | ||
return function wrap() { | ||
return fn.apply(thisArg, arguments); | ||
var args = new Array(arguments.length); | ||
for (var i = 0; i < args.length; i++) { | ||
args[i] = arguments[i]; | ||
} | ||
return fn.apply(thisArg, args); | ||
}; | ||
} | ||
}; |
'use strict'; | ||
import utils from '../utils.js'; | ||
import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js'; | ||
var utils = require('./../utils'); | ||
/** | ||
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their | ||
* URI encoded counterparts | ||
* | ||
* @param {string} val The value to be encoded. | ||
* | ||
* @returns {string} The encoded value. | ||
*/ | ||
function encode(val) { | ||
@@ -29,7 +20,5 @@ return encodeURIComponent(val). | ||
* @param {object} [params] The params to be appended | ||
* @param {?object} options | ||
* | ||
* @returns {string} The formatted url | ||
*/ | ||
export default function buildURL(url, params, options) { | ||
module.exports = function buildURL(url, params, paramsSerializer) { | ||
/*eslint no-param-reassign:0*/ | ||
@@ -39,23 +28,41 @@ if (!params) { | ||
} | ||
const _encode = options && options.encode || encode; | ||
const serializeFn = options && options.serialize; | ||
var serializedParams; | ||
if (paramsSerializer) { | ||
serializedParams = paramsSerializer(params); | ||
} else if (utils.isURLSearchParams(params)) { | ||
serializedParams = params.toString(); | ||
} else { | ||
var parts = []; | ||
let serializedParams; | ||
utils.forEach(params, function serialize(val, key) { | ||
if (val === null || typeof val === 'undefined') { | ||
return; | ||
} | ||
if (serializeFn) { | ||
serializedParams = serializeFn(params, options); | ||
} else { | ||
serializedParams = utils.isURLSearchParams(params) ? | ||
params.toString() : | ||
new AxiosURLSearchParams(params, options).toString(_encode); | ||
if (utils.isArray(val)) { | ||
key = key + '[]'; | ||
} else { | ||
val = [val]; | ||
} | ||
utils.forEach(val, function parseValue(v) { | ||
if (utils.isDate(v)) { | ||
v = v.toISOString(); | ||
} else if (utils.isObject(v)) { | ||
v = JSON.stringify(v); | ||
} | ||
parts.push(encode(key) + '=' + encode(v)); | ||
}); | ||
}); | ||
serializedParams = parts.join('&'); | ||
} | ||
if (serializedParams) { | ||
const hashmarkIndex = url.indexOf("#"); | ||
var hashmarkIndex = url.indexOf('#'); | ||
if (hashmarkIndex !== -1) { | ||
url = url.slice(0, hashmarkIndex); | ||
} | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; | ||
@@ -65,2 +72,2 @@ } | ||
return url; | ||
} | ||
}; |
@@ -8,9 +8,8 @@ 'use strict'; | ||
* @param {string} relativeURL The relative URL | ||
* | ||
* @returns {string} The combined URL | ||
*/ | ||
export default function combineURLs(baseURL, relativeURL) { | ||
module.exports = function combineURLs(baseURL, relativeURL) { | ||
return relativeURL | ||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') | ||
: baseURL; | ||
} | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
var utils = require('./../utils'); | ||
export default platform.isStandardBrowserEnv ? | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
// Standard browser envs support document.cookie | ||
(function standardBrowserEnv() { | ||
return { | ||
write: function write(name, value, expires, path, domain, secure) { | ||
const cookie = []; | ||
cookie.push(name + '=' + encodeURIComponent(value)); | ||
// Standard browser envs support document.cookie | ||
(function standardBrowserEnv() { | ||
return { | ||
write: function write(name, value, expires, path, domain, secure) { | ||
var cookie = []; | ||
cookie.push(name + '=' + encodeURIComponent(value)); | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
if (secure === true) { | ||
cookie.push('secure'); | ||
} | ||
if (secure === true) { | ||
cookie.push('secure'); | ||
} | ||
document.cookie = cookie.join('; '); | ||
}, | ||
document.cookie = cookie.join('; '); | ||
}, | ||
read: function read(name) { | ||
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
read: function read(name) { | ||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
remove: function remove(name) { | ||
this.write(name, '', Date.now() - 86400000); | ||
} | ||
}; | ||
})() : | ||
remove: function remove(name) { | ||
this.write(name, '', Date.now() - 86400000); | ||
} | ||
}; | ||
})() : | ||
// Non standard browser env (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return { | ||
write: function write() {}, | ||
read: function read() { return null; }, | ||
remove: function remove() {} | ||
}; | ||
})(); | ||
// Non standard browser env (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return { | ||
write: function write() {}, | ||
read: function read() { return null; }, | ||
remove: function remove() {} | ||
}; | ||
})() | ||
); |
@@ -12,6 +12,4 @@ 'use strict'; | ||
* @param {string} [docs] The documentation URL to get further details | ||
* | ||
* @returns {void} | ||
*/ | ||
export default function deprecatedMethod(method, instead, docs) { | ||
module.exports = function deprecatedMethod(method, instead, docs) { | ||
try { | ||
@@ -27,2 +25,2 @@ console.warn( | ||
} catch (e) { /* Ignore */ } | ||
} | ||
}; |
@@ -7,6 +7,5 @@ 'use strict'; | ||
* @param {string} url The URL to test | ||
* | ||
* @returns {boolean} True if the specified URL is absolute, otherwise false | ||
*/ | ||
export default function isAbsoluteURL(url) { | ||
module.exports = function isAbsoluteURL(url) { | ||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). | ||
@@ -16,2 +15,2 @@ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed | ||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); | ||
} | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
var utils = require('./../utils'); | ||
@@ -9,7 +9,6 @@ /** | ||
* @param {*} payload The value to test | ||
* | ||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false | ||
*/ | ||
export default function isAxiosError(payload) { | ||
module.exports = function isAxiosError(payload) { | ||
return utils.isObject(payload) && (payload.isAxiosError === true); | ||
} | ||
}; |
'use strict'; | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
var utils = require('./../utils'); | ||
export default platform.isStandardBrowserEnv ? | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
// Standard browser envs have full support of the APIs needed to test | ||
// whether the request URL is of the same origin as current location. | ||
(function standardBrowserEnv() { | ||
const msie = /(msie|trident)/i.test(navigator.userAgent); | ||
const urlParsingNode = document.createElement('a'); | ||
let originURL; | ||
// Standard browser envs have full support of the APIs needed to test | ||
// whether the request URL is of the same origin as current location. | ||
(function standardBrowserEnv() { | ||
var msie = /(msie|trident)/i.test(navigator.userAgent); | ||
var urlParsingNode = document.createElement('a'); | ||
var originURL; | ||
/** | ||
/** | ||
* Parse a URL to discover it's components | ||
@@ -21,31 +21,31 @@ * | ||
*/ | ||
function resolveURL(url) { | ||
let href = url; | ||
function resolveURL(url) { | ||
var href = url; | ||
if (msie) { | ||
if (msie) { | ||
// IE needs attribute set twice to normalize properties | ||
urlParsingNode.setAttribute('href', href); | ||
href = urlParsingNode.href; | ||
} | ||
urlParsingNode.setAttribute('href', href); | ||
href = urlParsingNode.href; | ||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | ||
return { | ||
href: urlParsingNode.href, | ||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | ||
host: urlParsingNode.host, | ||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | ||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | ||
hostname: urlParsingNode.hostname, | ||
port: urlParsingNode.port, | ||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | ||
urlParsingNode.pathname : | ||
'/' + urlParsingNode.pathname | ||
}; | ||
} | ||
urlParsingNode.setAttribute('href', href); | ||
originURL = resolveURL(window.location.href); | ||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | ||
return { | ||
href: urlParsingNode.href, | ||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | ||
host: urlParsingNode.host, | ||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | ||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | ||
hostname: urlParsingNode.hostname, | ||
port: urlParsingNode.port, | ||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | ||
urlParsingNode.pathname : | ||
'/' + urlParsingNode.pathname | ||
}; | ||
} | ||
originURL = resolveURL(window.location.href); | ||
/** | ||
/** | ||
* Determine if a URL shares the same origin as the current location | ||
@@ -56,14 +56,15 @@ * | ||
*/ | ||
return function isURLSameOrigin(requestURL) { | ||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
}; | ||
})() : | ||
return function isURLSameOrigin(requestURL) { | ||
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
}; | ||
})() : | ||
// Non standard browser envs (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})(); | ||
(function nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})() | ||
); |
// eslint-disable-next-line strict | ||
export default null; | ||
module.exports = null; |
'use strict'; | ||
import utils from './../utils.js'; | ||
var utils = require('./../utils'); | ||
// RawAxiosHeaders whose duplicates are ignored by node | ||
// Headers whose duplicates are ignored by node | ||
// c.f. https://nodejs.org/api/http.html#http_message_headers | ||
const ignoreDuplicateOf = utils.toObjectSet([ | ||
var ignoreDuplicateOf = [ | ||
'age', 'authorization', 'content-length', 'content-type', 'etag', | ||
@@ -12,3 +12,3 @@ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', | ||
'referer', 'retry-after', 'user-agent' | ||
]); | ||
]; | ||
@@ -25,29 +25,27 @@ /** | ||
* | ||
* @param {String} rawHeaders Headers needing to be parsed | ||
* | ||
* @param {String} headers Headers needing to be parsed | ||
* @returns {Object} Headers parsed into an object | ||
*/ | ||
export default rawHeaders => { | ||
const parsed = {}; | ||
let key; | ||
let val; | ||
let i; | ||
module.exports = function parseHeaders(headers) { | ||
var parsed = {}; | ||
var key; | ||
var val; | ||
var i; | ||
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) { | ||
if (!headers) { return parsed; } | ||
utils.forEach(headers.split('\n'), function parser(line) { | ||
i = line.indexOf(':'); | ||
key = line.substring(0, i).trim().toLowerCase(); | ||
val = line.substring(i + 1).trim(); | ||
key = utils.trim(line.substr(0, i)).toLowerCase(); | ||
val = utils.trim(line.substr(i + 1)); | ||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
if (parsed[key]) { | ||
parsed[key].push(val); | ||
if (key) { | ||
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); | ||
} else { | ||
parsed[key] = [val]; | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
} | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
} | ||
@@ -54,0 +52,0 @@ }); |
'use strict'; | ||
export default function parseProtocol(url) { | ||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); | ||
module.exports = function parseProtocol(url) { | ||
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); | ||
return match && match[1] || ''; | ||
} | ||
}; |
@@ -21,9 +21,8 @@ 'use strict'; | ||
* @param {Function} callback | ||
* | ||
* @returns {Function} | ||
*/ | ||
export default function spread(callback) { | ||
module.exports = function spread(callback) { | ||
return function wrap(arr) { | ||
return callback.apply(null, arr); | ||
}; | ||
} | ||
}; |
'use strict'; | ||
import utils from '../utils.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
// temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored | ||
import PlatformFormData from '../platform/node/classes/FormData.js'; | ||
var utils = require('../utils'); | ||
/** | ||
* Determines if the given thing is a array or js object. | ||
* | ||
* @param {string} thing - The object or array to be visited. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isVisitable(thing) { | ||
return utils.isPlainObject(thing) || utils.isArray(thing); | ||
} | ||
/** | ||
* It removes the brackets from the end of a string | ||
* | ||
* @param {string} key - The key of the parameter. | ||
* | ||
* @returns {string} the key without the brackets. | ||
*/ | ||
function removeBrackets(key) { | ||
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key; | ||
} | ||
/** | ||
* It takes a path, a key, and a boolean, and returns a string | ||
* | ||
* @param {string} path - The path to the current key. | ||
* @param {string} key - The key of the current object being iterated over. | ||
* @param {string} dots - If true, the key will be rendered with dots instead of brackets. | ||
* | ||
* @returns {string} The path to the current key. | ||
*/ | ||
function renderKey(path, key, dots) { | ||
if (!path) return key; | ||
return path.concat(key).map(function each(token, i) { | ||
// eslint-disable-next-line no-param-reassign | ||
token = removeBrackets(token); | ||
return !dots && i ? '[' + token + ']' : token; | ||
}).join(dots ? '.' : ''); | ||
} | ||
/** | ||
* If the array is an array and none of its elements are visitable, then it's a flat array. | ||
* | ||
* @param {Array<any>} arr - The array to check | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isFlatArray(arr) { | ||
return utils.isArray(arr) && !arr.some(isVisitable); | ||
} | ||
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) { | ||
return /^is[A-Z]/.test(prop); | ||
}); | ||
/** | ||
* Convert a data object to FormData | ||
* | ||
* @param {Object} obj | ||
* @param {?Object} [formData] | ||
* @param {?Object} [options] | ||
* @param {Function} [options.visitor] | ||
* @param {Boolean} [options.metaTokens = true] | ||
* @param {Boolean} [options.dots = false] | ||
* @param {?Boolean} [options.indexes = false] | ||
* | ||
* @returns {Object} | ||
**/ | ||
/** | ||
* It converts an object into a FormData object | ||
* | ||
* @param {Object<any, any>} obj - The object to convert to form data. | ||
* @param {string} formData - The FormData object to append to. | ||
* @param {Object<string, any>} options | ||
* | ||
* @returns | ||
*/ | ||
function toFormData(obj, formData, options) { | ||
if (!utils.isObject(obj)) { | ||
throw new TypeError('target must be an object'); | ||
} | ||
function toFormData(obj, formData) { | ||
// eslint-disable-next-line no-param-reassign | ||
formData = formData || new (PlatformFormData || FormData)(); | ||
formData = formData || new FormData(); | ||
// eslint-disable-next-line no-param-reassign | ||
options = utils.toFlatObject(options, { | ||
metaTokens: true, | ||
dots: false, | ||
indexes: false | ||
}, false, function defined(option, source) { | ||
// eslint-disable-next-line no-eq-null,eqeqeq | ||
return !utils.isUndefined(source[option]); | ||
}); | ||
var stack = []; | ||
const metaTokens = options.metaTokens; | ||
// eslint-disable-next-line no-use-before-define | ||
const visitor = options.visitor || defaultVisitor; | ||
const dots = options.dots; | ||
const indexes = options.indexes; | ||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob; | ||
const useBlob = _Blob && utils.isSpecCompliantForm(formData); | ||
if (!utils.isFunction(visitor)) { | ||
throw new TypeError('visitor must be a function'); | ||
} | ||
function convertValue(value) { | ||
@@ -123,8 +25,4 @@ if (value === null) return ''; | ||
if (!useBlob && utils.isBlob(value)) { | ||
throw new AxiosError('Blob is not supported. Use a Buffer instead.'); | ||
} | ||
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) { | ||
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value); | ||
return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value); | ||
} | ||
@@ -135,82 +33,37 @@ | ||
/** | ||
* Default visitor. | ||
* | ||
* @param {*} value | ||
* @param {String|Number} key | ||
* @param {Array<String|Number>} path | ||
* @this {FormData} | ||
* | ||
* @returns {boolean} return true to visit the each prop of the value recursively | ||
*/ | ||
function defaultVisitor(value, key, path) { | ||
let arr = value; | ||
if (value && !path && typeof value === 'object') { | ||
if (utils.endsWith(key, '{}')) { | ||
// eslint-disable-next-line no-param-reassign | ||
key = metaTokens ? key : key.slice(0, -2); | ||
// eslint-disable-next-line no-param-reassign | ||
value = JSON.stringify(value); | ||
} else if ( | ||
(utils.isArray(value) && isFlatArray(value)) || | ||
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)) | ||
)) { | ||
// eslint-disable-next-line no-param-reassign | ||
key = removeBrackets(key); | ||
arr.forEach(function each(el, index) { | ||
!(utils.isUndefined(el) || el === null) && formData.append( | ||
// eslint-disable-next-line no-nested-ternary | ||
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'), | ||
convertValue(el) | ||
); | ||
}); | ||
return false; | ||
function build(data, parentKey) { | ||
if (utils.isPlainObject(data) || utils.isArray(data)) { | ||
if (stack.indexOf(data) !== -1) { | ||
throw Error('Circular reference detected in ' + parentKey); | ||
} | ||
} | ||
if (isVisitable(value)) { | ||
return true; | ||
} | ||
stack.push(data); | ||
formData.append(renderKey(path, key, dots), convertValue(value)); | ||
utils.forEach(data, function each(value, key) { | ||
if (utils.isUndefined(value)) return; | ||
var fullKey = parentKey ? parentKey + '.' + key : key; | ||
var arr; | ||
return false; | ||
} | ||
if (value && !parentKey && typeof value === 'object') { | ||
if (utils.endsWith(key, '{}')) { | ||
// eslint-disable-next-line no-param-reassign | ||
value = JSON.stringify(value); | ||
} else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) { | ||
// eslint-disable-next-line func-names | ||
arr.forEach(function(el) { | ||
!utils.isUndefined(el) && formData.append(fullKey, convertValue(el)); | ||
}); | ||
return; | ||
} | ||
} | ||
const stack = []; | ||
build(value, fullKey); | ||
}); | ||
const exposedHelpers = Object.assign(predicates, { | ||
defaultVisitor, | ||
convertValue, | ||
isVisitable | ||
}); | ||
function build(value, path) { | ||
if (utils.isUndefined(value)) return; | ||
if (stack.indexOf(value) !== -1) { | ||
throw Error('Circular reference detected in ' + path.join('.')); | ||
stack.pop(); | ||
} else { | ||
formData.append(parentKey, convertValue(data)); | ||
} | ||
stack.push(value); | ||
utils.forEach(value, function each(el, key) { | ||
const result = !(utils.isUndefined(el) || el === null) && visitor.call( | ||
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers | ||
); | ||
if (result === true) { | ||
build(el, path ? path.concat(key) : [key]); | ||
} | ||
}); | ||
stack.pop(); | ||
} | ||
if (!utils.isObject(obj)) { | ||
throw new TypeError('data must be an object'); | ||
} | ||
build(obj); | ||
@@ -221,2 +74,2 @@ | ||
export default toFormData; | ||
module.exports = toFormData; |
'use strict'; | ||
import {VERSION} from '../env/data.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
var VERSION = require('../env/data').version; | ||
var AxiosError = require('../core/AxiosError'); | ||
const validators = {}; | ||
var validators = {}; | ||
// eslint-disable-next-line func-names | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => { | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { | ||
validators[type] = function validator(thing) { | ||
@@ -15,11 +15,9 @@ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; | ||
const deprecatedWarnings = {}; | ||
var deprecatedWarnings = {}; | ||
/** | ||
* Transitional option validator | ||
* | ||
* @param {function|boolean?} validator - set to false if the transitional option has been removed | ||
* @param {string?} version - deprecated version / removed since version | ||
* @param {string?} message - some message with additional info | ||
* | ||
* @returns {function} | ||
@@ -33,3 +31,3 @@ */ | ||
// eslint-disable-next-line func-names | ||
return (value, opt, opts) => { | ||
return function(value, opt, opts) { | ||
if (validator === false) { | ||
@@ -59,8 +57,5 @@ throw new AxiosError( | ||
* Assert object's properties type | ||
* | ||
* @param {object} options | ||
* @param {object} schema | ||
* @param {boolean?} allowUnknown | ||
* | ||
* @returns {object} | ||
*/ | ||
@@ -72,10 +67,10 @@ | ||
} | ||
const keys = Object.keys(options); | ||
let i = keys.length; | ||
var keys = Object.keys(options); | ||
var i = keys.length; | ||
while (i-- > 0) { | ||
const opt = keys[i]; | ||
const validator = schema[opt]; | ||
var opt = keys[i]; | ||
var validator = schema[opt]; | ||
if (validator) { | ||
const value = options[opt]; | ||
const result = value === undefined || validator(value, opt, options); | ||
var value = options[opt]; | ||
var result = value === undefined || validator(value, opt, options); | ||
if (result !== true) { | ||
@@ -92,5 +87,5 @@ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); | ||
export default { | ||
assertOptions, | ||
validators | ||
module.exports = { | ||
assertOptions: assertOptions, | ||
validators: validators | ||
}; |
624
lib/utils.js
'use strict'; | ||
import bind from './helpers/bind.js'; | ||
var bind = require('./helpers/bind'); | ||
// utils is a library of generic helper functions non-specific to axios | ||
const {toString} = Object.prototype; | ||
const {getPrototypeOf} = Object; | ||
var toString = Object.prototype.toString; | ||
const kindOf = (cache => thing => { | ||
const str = toString.call(thing); | ||
// eslint-disable-next-line func-names | ||
var kindOf = (function(cache) { | ||
// eslint-disable-next-line func-names | ||
return function(thing) { | ||
var str = toString.call(thing); | ||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); | ||
}; | ||
})(Object.create(null)); | ||
const kindOfTest = (type) => { | ||
function kindOfTest(type) { | ||
type = type.toLowerCase(); | ||
return (thing) => kindOf(thing) === type | ||
return function isKindOf(thing) { | ||
return kindOf(thing) === type; | ||
}; | ||
} | ||
const typeOfTest = type => thing => typeof thing === type; | ||
/** | ||
@@ -26,6 +29,7 @@ * Determine if a value is an Array | ||
* @param {Object} val The value to test | ||
* | ||
* @returns {boolean} True if value is an Array, otherwise false | ||
*/ | ||
const {isArray} = Array; | ||
function isArray(val) { | ||
return Array.isArray(val); | ||
} | ||
@@ -35,7 +39,8 @@ /** | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if the value is undefined, otherwise false | ||
*/ | ||
const isUndefined = typeOfTest('undefined'); | ||
function isUndefined(val) { | ||
return typeof val === 'undefined'; | ||
} | ||
@@ -45,4 +50,3 @@ /** | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Buffer, otherwise false | ||
@@ -52,3 +56,3 @@ */ | ||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) | ||
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val); | ||
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); | ||
} | ||
@@ -59,7 +63,7 @@ | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false | ||
*/ | ||
const isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
var isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
@@ -70,8 +74,7 @@ | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBufferView(val) { | ||
let result; | ||
var result; | ||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { | ||
@@ -88,24 +91,18 @@ result = ArrayBuffer.isView(val); | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a String, otherwise false | ||
*/ | ||
const isString = typeOfTest('string'); | ||
function isString(val) { | ||
return typeof val === 'string'; | ||
} | ||
/** | ||
* Determine if a value is a Function | ||
* | ||
* @param {*} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
*/ | ||
const isFunction = typeOfTest('function'); | ||
/** | ||
* Determine if a value is a Number | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Number, otherwise false | ||
*/ | ||
const isNumber = typeOfTest('number'); | ||
function isNumber(val) { | ||
return typeof val === 'number'; | ||
} | ||
@@ -115,24 +112,16 @@ /** | ||
* | ||
* @param {*} thing The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an Object, otherwise false | ||
*/ | ||
const isObject = (thing) => thing !== null && typeof thing === 'object'; | ||
function isObject(val) { | ||
return val !== null && typeof val === 'object'; | ||
} | ||
/** | ||
* Determine if a value is a Boolean | ||
* | ||
* @param {*} thing The value to test | ||
* @returns {boolean} True if value is a Boolean, otherwise false | ||
*/ | ||
const isBoolean = thing => thing === true || thing === false; | ||
/** | ||
* Determine if a value is a plain Object | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a plain Object, otherwise false | ||
* @param {Object} val The value to test | ||
* @return {boolean} True if value is a plain Object, otherwise false | ||
*/ | ||
const isPlainObject = (val) => { | ||
function isPlainObject(val) { | ||
if (kindOf(val) !== 'object') { | ||
@@ -142,4 +131,4 @@ return false; | ||
const prototype = getPrototypeOf(val); | ||
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val); | ||
var prototype = Object.getPrototypeOf(val); | ||
return prototype === null || prototype === Object.prototype; | ||
} | ||
@@ -150,7 +139,7 @@ | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Date, otherwise false | ||
*/ | ||
const isDate = kindOfTest('Date'); | ||
var isDate = kindOfTest('Date'); | ||
@@ -160,7 +149,7 @@ /** | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
const isFile = kindOfTest('File'); | ||
var isFile = kindOfTest('File'); | ||
@@ -170,7 +159,7 @@ /** | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Blob, otherwise false | ||
*/ | ||
const isBlob = kindOfTest('Blob'); | ||
var isBlob = kindOfTest('Blob'); | ||
@@ -180,16 +169,27 @@ /** | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
const isFileList = kindOfTest('FileList'); | ||
var isFileList = kindOfTest('FileList'); | ||
/** | ||
* Determine if a value is a Function | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
*/ | ||
function isFunction(val) { | ||
return toString.call(val) === '[object Function]'; | ||
} | ||
/** | ||
* Determine if a value is a Stream | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Stream, otherwise false | ||
*/ | ||
const isStream = (val) => isObject(val) && isFunction(val.pipe); | ||
function isStream(val) { | ||
return isObject(val) && isFunction(val.pipe); | ||
} | ||
@@ -199,17 +199,12 @@ /** | ||
* | ||
* @param {*} thing The value to test | ||
* | ||
* @param {Object} thing The value to test | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
const isFormData = (thing) => { | ||
let kind; | ||
function isFormData(thing) { | ||
var pattern = '[object FormData]'; | ||
return thing && ( | ||
(typeof FormData === 'function' && thing instanceof FormData) || ( | ||
isFunction(thing.append) && ( | ||
(kind = kindOf(thing)) === 'formdata' || | ||
// detect form-data instance | ||
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]') | ||
) | ||
) | ||
) | ||
(typeof FormData === 'function' && thing instanceof FormData) || | ||
toString.call(thing) === pattern || | ||
(isFunction(thing.toString) && thing.toString() === pattern) | ||
); | ||
} | ||
@@ -219,8 +214,7 @@ | ||
* Determine if a value is a URLSearchParams object | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false | ||
*/ | ||
const isURLSearchParams = kindOfTest('URLSearchParams'); | ||
var isURLSearchParams = kindOfTest('URLSearchParams'); | ||
@@ -231,9 +225,36 @@ /** | ||
* @param {String} str The String to trim | ||
* | ||
* @returns {String} The String freed of excess whitespace | ||
*/ | ||
const trim = (str) => str.trim ? | ||
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | ||
function trim(str) { | ||
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); | ||
} | ||
/** | ||
* Determine if we're running in a standard browser environment | ||
* | ||
* This allows axios to run in a web worker, and react-native. | ||
* Both environments support XMLHttpRequest, but not fully standard globals. | ||
* | ||
* web workers: | ||
* typeof window -> undefined | ||
* typeof document -> undefined | ||
* | ||
* react-native: | ||
* navigator.product -> 'ReactNative' | ||
* nativescript | ||
* navigator.product -> 'NativeScript' or 'NS' | ||
*/ | ||
function isStandardBrowserEnv() { | ||
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || | ||
navigator.product === 'NativeScript' || | ||
navigator.product === 'NS')) { | ||
return false; | ||
} | ||
return ( | ||
typeof window !== 'undefined' && | ||
typeof document !== 'undefined' | ||
); | ||
} | ||
/** | ||
* Iterate over an Array or an Object invoking a function for each item. | ||
@@ -249,7 +270,4 @@ * | ||
* @param {Function} fn The callback to invoke for each item | ||
* | ||
* @param {Boolean} [allOwnKeys = false] | ||
* @returns {any} | ||
*/ | ||
function forEach(obj, fn, {allOwnKeys = false} = {}) { | ||
function forEach(obj, fn) { | ||
// Don't bother if no value provided | ||
@@ -260,5 +278,2 @@ if (obj === null || typeof obj === 'undefined') { | ||
let i; | ||
let l; | ||
// Force an array if not already something iterable | ||
@@ -272,3 +287,3 @@ if (typeof obj !== 'object') { | ||
// Iterate over array values | ||
for (i = 0, l = obj.length; i < l; i++) { | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
fn.call(null, obj[i], i, obj); | ||
@@ -278,9 +293,6 @@ } | ||
// Iterate over object keys | ||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj); | ||
const len = keys.length; | ||
let key; | ||
for (i = 0; i < len; i++) { | ||
key = keys[i]; | ||
fn.call(null, obj[key], key, obj); | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
fn.call(null, obj[key], key, obj); | ||
} | ||
} | ||
@@ -290,24 +302,2 @@ } | ||
function findKey(obj, key) { | ||
key = key.toLowerCase(); | ||
const keys = Object.keys(obj); | ||
let i = keys.length; | ||
let _key; | ||
while (i-- > 0) { | ||
_key = keys[i]; | ||
if (key === _key.toLowerCase()) { | ||
return _key; | ||
} | ||
} | ||
return null; | ||
} | ||
const _global = (() => { | ||
/*eslint no-undef:0*/ | ||
if (typeof globalThis !== "undefined") return globalThis; | ||
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global) | ||
})(); | ||
const isContextDefined = (context) => !isUndefined(context) && context !== _global; | ||
/** | ||
@@ -328,23 +318,20 @@ * Accepts varargs expecting each argument to be an object, then | ||
* @param {Object} obj1 Object to merge | ||
* | ||
* @returns {Object} Result of all merge properties | ||
*/ | ||
function merge(/* obj1, obj2, obj3, ... */) { | ||
const {caseless} = isContextDefined(this) && this || {}; | ||
const result = {}; | ||
const assignValue = (val, key) => { | ||
const targetKey = caseless && findKey(result, key) || key; | ||
if (isPlainObject(result[targetKey]) && isPlainObject(val)) { | ||
result[targetKey] = merge(result[targetKey], val); | ||
var result = {}; | ||
function assignValue(val, key) { | ||
if (isPlainObject(result[key]) && isPlainObject(val)) { | ||
result[key] = merge(result[key], val); | ||
} else if (isPlainObject(val)) { | ||
result[targetKey] = merge({}, val); | ||
result[key] = merge({}, val); | ||
} else if (isArray(val)) { | ||
result[targetKey] = val.slice(); | ||
result[key] = val.slice(); | ||
} else { | ||
result[targetKey] = val; | ||
result[key] = val; | ||
} | ||
} | ||
for (let i = 0, l = arguments.length; i < l; i++) { | ||
arguments[i] && forEach(arguments[i], assignValue); | ||
for (var i = 0, l = arguments.length; i < l; i++) { | ||
forEach(arguments[i], assignValue); | ||
} | ||
@@ -360,9 +347,7 @@ return result; | ||
* @param {Object} thisArg The object to bind function to | ||
* | ||
* @param {Boolean} [allOwnKeys] | ||
* @returns {Object} The resulting value of object a | ||
* @return {Object} The resulting value of object a | ||
*/ | ||
const extend = (a, b, thisArg, {allOwnKeys}= {}) => { | ||
forEach(b, (val, key) => { | ||
if (thisArg && isFunction(val)) { | ||
function extend(a, b, thisArg) { | ||
forEach(b, function assignValue(val, key) { | ||
if (thisArg && typeof val === 'function') { | ||
a[key] = bind(val, thisArg); | ||
@@ -372,3 +357,3 @@ } else { | ||
} | ||
}, {allOwnKeys}); | ||
}); | ||
return a; | ||
@@ -381,6 +366,5 @@ } | ||
* @param {string} content with BOM | ||
* | ||
* @returns {string} content value without BOM | ||
* @return {string} content value without BOM | ||
*/ | ||
const stripBOM = (content) => { | ||
function stripBOM(content) { | ||
if (content.charCodeAt(0) === 0xFEFF) { | ||
@@ -398,11 +382,7 @@ content = content.slice(1); | ||
* @param {object} [descriptors] | ||
* | ||
* @returns {void} | ||
*/ | ||
const inherits = (constructor, superConstructor, props, descriptors) => { | ||
function inherits(constructor, superConstructor, props, descriptors) { | ||
constructor.prototype = Object.create(superConstructor.prototype, descriptors); | ||
constructor.prototype.constructor = constructor; | ||
Object.defineProperty(constructor, 'super', { | ||
value: superConstructor.prototype | ||
}); | ||
props && Object.assign(constructor.prototype, props); | ||
@@ -415,16 +395,13 @@ } | ||
* @param {Object} [destObj] | ||
* @param {Function|Boolean} [filter] | ||
* @param {Function} [propFilter] | ||
* | ||
* @param {Function} [filter] | ||
* @returns {Object} | ||
*/ | ||
const toFlatObject = (sourceObj, destObj, filter, propFilter) => { | ||
let props; | ||
let i; | ||
let prop; | ||
const merged = {}; | ||
function toFlatObject(sourceObj, destObj, filter) { | ||
var props; | ||
var i; | ||
var prop; | ||
var merged = {}; | ||
destObj = destObj || {}; | ||
// eslint-disable-next-line no-eq-null,eqeqeq | ||
if (sourceObj == null) return destObj; | ||
@@ -436,3 +413,3 @@ do { | ||
prop = props[i]; | ||
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) { | ||
if (!merged[prop]) { | ||
destObj[prop] = sourceObj[prop]; | ||
@@ -442,3 +419,3 @@ merged[prop] = true; | ||
} | ||
sourceObj = filter !== false && getPrototypeOf(sourceObj); | ||
sourceObj = Object.getPrototypeOf(sourceObj); | ||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); | ||
@@ -449,12 +426,10 @@ | ||
/** | ||
* Determines whether a string ends with the characters of a specified string | ||
* | ||
/* | ||
* determines whether a string ends with the characters of a specified string | ||
* @param {String} str | ||
* @param {String} searchString | ||
* @param {Number} [position= 0] | ||
* | ||
* @returns {boolean} | ||
*/ | ||
const endsWith = (str, searchString, position) => { | ||
function endsWith(str, searchString, position) { | ||
str = String(str); | ||
@@ -465,3 +440,3 @@ if (position === undefined || position > str.length) { | ||
position -= searchString.length; | ||
const lastIndex = str.indexOf(searchString, position); | ||
var lastIndex = str.indexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
@@ -472,14 +447,11 @@ } | ||
/** | ||
* Returns new array from array like object or null if failed | ||
* | ||
* Returns new array from array like object | ||
* @param {*} [thing] | ||
* | ||
* @returns {?Array} | ||
* @returns {Array} | ||
*/ | ||
const toArray = (thing) => { | ||
function toArray(thing) { | ||
if (!thing) return null; | ||
if (isArray(thing)) return thing; | ||
let i = thing.length; | ||
if (!isNumber(i)) return null; | ||
const arr = new Array(i); | ||
var i = thing.length; | ||
if (isUndefined(i)) return null; | ||
var arr = new Array(i); | ||
while (i-- > 0) { | ||
@@ -491,265 +463,41 @@ arr[i] = thing[i]; | ||
/** | ||
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the | ||
* thing passed in is an instance of Uint8Array | ||
* | ||
* @param {TypedArray} | ||
* | ||
* @returns {Array} | ||
*/ | ||
// eslint-disable-next-line func-names | ||
const isTypedArray = (TypedArray => { | ||
var isTypedArray = (function(TypedArray) { | ||
// eslint-disable-next-line func-names | ||
return thing => { | ||
return function(thing) { | ||
return TypedArray && thing instanceof TypedArray; | ||
}; | ||
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array)); | ||
})(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array)); | ||
/** | ||
* For each entry in the object, call the function with the key and value. | ||
* | ||
* @param {Object<any, any>} obj - The object to iterate over. | ||
* @param {Function} fn - The function to call for each entry. | ||
* | ||
* @returns {void} | ||
*/ | ||
const forEachEntry = (obj, fn) => { | ||
const generator = obj && obj[Symbol.iterator]; | ||
const iterator = generator.call(obj); | ||
let result; | ||
while ((result = iterator.next()) && !result.done) { | ||
const pair = result.value; | ||
fn.call(obj, pair[0], pair[1]); | ||
} | ||
} | ||
/** | ||
* It takes a regular expression and a string, and returns an array of all the matches | ||
* | ||
* @param {string} regExp - The regular expression to match against. | ||
* @param {string} str - The string to search. | ||
* | ||
* @returns {Array<boolean>} | ||
*/ | ||
const matchAll = (regExp, str) => { | ||
let matches; | ||
const arr = []; | ||
while ((matches = regExp.exec(str)) !== null) { | ||
arr.push(matches); | ||
} | ||
return arr; | ||
} | ||
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */ | ||
const isHTMLForm = kindOfTest('HTMLFormElement'); | ||
const toCamelCase = str => { | ||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, | ||
function replacer(m, p1, p2) { | ||
return p1.toUpperCase() + p2; | ||
} | ||
); | ||
module.exports = { | ||
isArray: isArray, | ||
isArrayBuffer: isArrayBuffer, | ||
isBuffer: isBuffer, | ||
isFormData: isFormData, | ||
isArrayBufferView: isArrayBufferView, | ||
isString: isString, | ||
isNumber: isNumber, | ||
isObject: isObject, | ||
isPlainObject: isPlainObject, | ||
isUndefined: isUndefined, | ||
isDate: isDate, | ||
isFile: isFile, | ||
isBlob: isBlob, | ||
isFunction: isFunction, | ||
isStream: isStream, | ||
isURLSearchParams: isURLSearchParams, | ||
isStandardBrowserEnv: isStandardBrowserEnv, | ||
forEach: forEach, | ||
merge: merge, | ||
extend: extend, | ||
trim: trim, | ||
stripBOM: stripBOM, | ||
inherits: inherits, | ||
toFlatObject: toFlatObject, | ||
kindOf: kindOf, | ||
kindOfTest: kindOfTest, | ||
endsWith: endsWith, | ||
toArray: toArray, | ||
isTypedArray: isTypedArray, | ||
isFileList: isFileList | ||
}; | ||
/* Creating a function that will check if an object has a property. */ | ||
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype); | ||
/** | ||
* Determine if a value is a RegExp object | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a RegExp object, otherwise false | ||
*/ | ||
const isRegExp = kindOfTest('RegExp'); | ||
const reduceDescriptors = (obj, reducer) => { | ||
const descriptors = Object.getOwnPropertyDescriptors(obj); | ||
const reducedDescriptors = {}; | ||
forEach(descriptors, (descriptor, name) => { | ||
if (reducer(descriptor, name, obj) !== false) { | ||
reducedDescriptors[name] = descriptor; | ||
} | ||
}); | ||
Object.defineProperties(obj, reducedDescriptors); | ||
} | ||
/** | ||
* Makes all methods read-only | ||
* @param {Object} obj | ||
*/ | ||
const freezeMethods = (obj) => { | ||
reduceDescriptors(obj, (descriptor, name) => { | ||
// skip restricted props in strict mode | ||
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) { | ||
return false; | ||
} | ||
const value = obj[name]; | ||
if (!isFunction(value)) return; | ||
descriptor.enumerable = false; | ||
if ('writable' in descriptor) { | ||
descriptor.writable = false; | ||
return; | ||
} | ||
if (!descriptor.set) { | ||
descriptor.set = () => { | ||
throw Error('Can not rewrite read-only method \'' + name + '\''); | ||
}; | ||
} | ||
}); | ||
} | ||
const toObjectSet = (arrayOrString, delimiter) => { | ||
const obj = {}; | ||
const define = (arr) => { | ||
arr.forEach(value => { | ||
obj[value] = true; | ||
}); | ||
} | ||
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter)); | ||
return obj; | ||
} | ||
const noop = () => {} | ||
const toFiniteNumber = (value, defaultValue) => { | ||
value = +value; | ||
return Number.isFinite(value) ? value : defaultValue; | ||
} | ||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz' | ||
const DIGIT = '0123456789'; | ||
const ALPHABET = { | ||
DIGIT, | ||
ALPHA, | ||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT | ||
} | ||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => { | ||
let str = ''; | ||
const {length} = alphabet; | ||
while (size--) { | ||
str += alphabet[Math.random() * length|0] | ||
} | ||
return str; | ||
} | ||
/** | ||
* If the thing is a FormData object, return true, otherwise return false. | ||
* | ||
* @param {unknown} thing - The thing to check. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isSpecCompliantForm(thing) { | ||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]); | ||
} | ||
const toJSONObject = (obj) => { | ||
const stack = new Array(10); | ||
const visit = (source, i) => { | ||
if (isObject(source)) { | ||
if (stack.indexOf(source) >= 0) { | ||
return; | ||
} | ||
if(!('toJSON' in source)) { | ||
stack[i] = source; | ||
const target = isArray(source) ? [] : {}; | ||
forEach(source, (value, key) => { | ||
const reducedValue = visit(value, i + 1); | ||
!isUndefined(reducedValue) && (target[key] = reducedValue); | ||
}); | ||
stack[i] = undefined; | ||
return target; | ||
} | ||
} | ||
return source; | ||
} | ||
return visit(obj, 0); | ||
} | ||
const isAsyncFn = kindOfTest('AsyncFunction'); | ||
const isThenable = (thing) => | ||
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch); | ||
export default { | ||
isArray, | ||
isArrayBuffer, | ||
isBuffer, | ||
isFormData, | ||
isArrayBufferView, | ||
isString, | ||
isNumber, | ||
isBoolean, | ||
isObject, | ||
isPlainObject, | ||
isUndefined, | ||
isDate, | ||
isFile, | ||
isBlob, | ||
isRegExp, | ||
isFunction, | ||
isStream, | ||
isURLSearchParams, | ||
isTypedArray, | ||
isFileList, | ||
forEach, | ||
merge, | ||
extend, | ||
trim, | ||
stripBOM, | ||
inherits, | ||
toFlatObject, | ||
kindOf, | ||
kindOfTest, | ||
endsWith, | ||
toArray, | ||
forEachEntry, | ||
matchAll, | ||
isHTMLForm, | ||
hasOwnProperty, | ||
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection | ||
reduceDescriptors, | ||
freezeMethods, | ||
toObjectSet, | ||
toCamelCase, | ||
noop, | ||
toFiniteNumber, | ||
findKey, | ||
global: _global, | ||
isContextDefined, | ||
ALPHABET, | ||
generateString, | ||
isSpecCompliantForm, | ||
toJSONObject, | ||
isAsyncFn, | ||
isThenable | ||
}; |
184
package.json
{ | ||
"name": "axios", | ||
"version": "1.4.0", | ||
"version": "0.27.2", | ||
"description": "Promise based HTTP client for the browser and node.js", | ||
"main": "index.js", | ||
"exports": { | ||
".": { | ||
"types": { | ||
"require": "./index.d.cts", | ||
"default": "./index.d.ts" | ||
}, | ||
"browser": { | ||
"require": "./dist/browser/axios.cjs", | ||
"default": "./index.js" | ||
}, | ||
"default": { | ||
"require": "./dist/node/axios.cjs", | ||
"default": "./index.js" | ||
} | ||
}, | ||
"./unsafe/*": "./lib/*", | ||
"./unsafe/core/settle.js": "./lib/core/settle.js", | ||
"./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js", | ||
"./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js", | ||
"./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js", | ||
"./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js", | ||
"./unsafe/adapters/http.js": "./lib/adapters/http.js", | ||
"./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/utils.js": "./lib/utils.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports", | ||
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js", | ||
"test:dtslint": "dtslint --localTs node_modules/typescript/lib", | ||
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit", | ||
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit", | ||
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run", | ||
"test:karma:firefox": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: Browsers=Firefox karma start karma.conf.cjs --single-run", | ||
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs", | ||
"test:build:version": "node ./bin/check-build-version.js", | ||
"test": "grunt test && dtslint", | ||
"start": "node ./sandbox/server.js", | ||
"preversion": "gulp version", | ||
"version": "npm run build && git add dist && git add package.json", | ||
"prepublishOnly": "npm run test:build:version", | ||
"postpublish": "git push && git push --tags", | ||
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m", | ||
"preversion": "grunt version && npm test", | ||
"build": "NODE_ENV=production grunt build", | ||
"examples": "node ./examples/server.js", | ||
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"fix": "eslint --fix lib/**/*.js", | ||
"prepare": "husky install && npm run prepare:hooks", | ||
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"", | ||
"release:dry": "release-it --dry-run --no-npm", | ||
"release:info": "release-it --release-version", | ||
"release:beta:no-npm": "release-it --preRelease=beta --no-npm", | ||
"release:beta": "release-it --preRelease=beta", | ||
"release:no-npm": "release-it --no-npm", | ||
"release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md", | ||
"release": "release-it" | ||
"fix": "eslint --fix lib/**/*.js" | ||
}, | ||
@@ -81,31 +34,16 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"@commitlint/cli": "^17.3.0", | ||
"@commitlint/config-conventional": "^17.3.0", | ||
"@release-it/conventional-changelog": "^5.1.1", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-multi-entry": "^4.0.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"abortcontroller-polyfill": "^1.7.3", | ||
"auto-changelog": "^2.4.0", | ||
"body-parser": "^1.20.0", | ||
"chalk": "^5.2.0", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"dev-null": "^0.1.1", | ||
"dtslint": "^4.2.1", | ||
"es6-promise": "^4.2.8", | ||
"eslint": "^8.17.0", | ||
"express": "^4.18.1", | ||
"formdata-node": "^5.0.0", | ||
"formidable": "^2.0.1", | ||
"fs-extra": "^10.1.0", | ||
"get-stream": "^3.0.0", | ||
"gulp": "^4.0.2", | ||
"gzip-size": "^7.0.0", | ||
"handlebars": "^4.7.7", | ||
"husky": "^8.0.2", | ||
"grunt": "^1.4.1", | ||
"grunt-banner": "^0.6.0", | ||
"grunt-cli": "^1.4.3", | ||
"grunt-contrib-clean": "^2.0.0", | ||
"grunt-contrib-watch": "^1.1.0", | ||
"grunt-eslint": "^24.0.0", | ||
"grunt-karma": "^4.0.2", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-webpack": "^5.0.0", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
@@ -118,3 +56,2 @@ "jasmine-core": "^2.4.1", | ||
"karma-jasmine-ajax": "^0.1.13", | ||
"karma-rollup-preprocessor": "^7.0.8", | ||
"karma-safari-launcher": "^1.0.0", | ||
@@ -124,21 +61,16 @@ "karma-sauce-launcher": "^4.3.6", | ||
"karma-sourcemap-loader": "^0.3.8", | ||
"minimist": "^1.2.7", | ||
"mocha": "^10.0.0", | ||
"multer": "^1.4.4", | ||
"pretty-bytes": "^6.0.0", | ||
"release-it": "^15.5.1", | ||
"rollup": "^2.67.0", | ||
"rollup-plugin-auto-external": "^2.0.0", | ||
"rollup-plugin-bundle-size": "^1.0.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"karma-webpack": "^4.0.2", | ||
"load-grunt-tasks": "^5.1.0", | ||
"minimist": "^1.2.6", | ||
"mocha": "^8.2.1", | ||
"sinon": "^4.5.0", | ||
"stream-throttle": "^0.1.3", | ||
"string-replace-async": "^3.0.2", | ||
"terser-webpack-plugin": "^4.2.3", | ||
"typescript": "^4.8.4" | ||
"typescript": "^4.6.3", | ||
"url-search-params": "^0.10.0", | ||
"webpack": "^4.44.2", | ||
"webpack-dev-server": "^3.11.0" | ||
}, | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/helpers/null.js", | ||
"./lib/platform/node/index.js": "./lib/platform/browser/index.js", | ||
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js" | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js", | ||
"./lib/defaults/env/FormData.js": "./lib/helpers/null.js" | ||
}, | ||
@@ -149,5 +81,4 @@ "jsdelivr": "dist/axios.min.js", | ||
"dependencies": { | ||
"follow-redirects": "^1.15.0", | ||
"form-data": "^4.0.0", | ||
"proxy-from-env": "^1.1.0" | ||
"follow-redirects": "^1.14.9", | ||
"form-data": "^4.0.0" | ||
}, | ||
@@ -159,62 +90,3 @@ "bundlesize": [ | ||
} | ||
], | ||
"contributors": [ | ||
"Matt Zabriskie (https://github.com/mzabriskie)", | ||
"Nick Uraltsev (https://github.com/nickuraltsev)", | ||
"Jay (https://github.com/jasonsaayman)", | ||
"Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)", | ||
"Emily Morehouse (https://github.com/emilyemorehouse)", | ||
"RubΓ©n Norte (https://github.com/rubennorte)", | ||
"Justin Beckwith (https://github.com/JustinBeckwith)", | ||
"Martti Laine (https://github.com/codeclown)", | ||
"Xianming Zhong (https://github.com/chinesedfan)", | ||
"Rikki Gibson (https://github.com/RikkiGibson)", | ||
"Remco Haszing (https://github.com/remcohaszing)", | ||
"Yasu Flores (https://github.com/yasuf)", | ||
"Ben Carp (https://github.com/carpben)" | ||
], | ||
"sideEffects": false, | ||
"release-it": { | ||
"git": { | ||
"commitMessage": "chore(release): v${version}", | ||
"push": true, | ||
"commit": true, | ||
"tag": true, | ||
"requireCommits": false, | ||
"requireCleanWorkingDir": false | ||
}, | ||
"github": { | ||
"release": true, | ||
"draft": true | ||
}, | ||
"npm": { | ||
"publish": false, | ||
"ignoreVersion": false | ||
}, | ||
"plugins": { | ||
"@release-it/conventional-changelog": { | ||
"preset": "angular", | ||
"infile": "CHANGELOG.md", | ||
"header": "# Changelog" | ||
} | ||
}, | ||
"hooks": { | ||
"before:init": "npm test", | ||
"after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version && git add ./dist && git add ./package-lock.json", | ||
"before:release": "npm run release:changelog:fix", | ||
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}." | ||
} | ||
}, | ||
"commitlint": { | ||
"rules": { | ||
"header-max-length": [ | ||
2, | ||
"always", | ||
130 | ||
] | ||
}, | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
} | ||
} | ||
] | ||
} |
566
README.md
@@ -1,24 +0,10 @@ | ||
<h1 align="center"> | ||
<b> | ||
<a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br> | ||
</b> | ||
</h1> | ||
# axios | ||
<p align="center">Promise based HTTP client for the browser and node.js</p> | ||
<p align="center"> | ||
<a href="https://axios-http.com/"><b>Website</b></a> β’ | ||
<a href="https://axios-http.com/docs/intro"><b>Documentation</b></a> | ||
</p> | ||
<div align="center"> | ||
[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios) | ||
[![Build status](https://img.shields.io/github/actions/workflow/status/axios/axios/ci.yml?branch=v1.x&label=CI&logo=github&style=flat-square)](https://github.com/axios/axios/actions/workflows/ci.yml) | ||
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/axios/axios) | ||
![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg) | ||
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios) | ||
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) | ||
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=axios&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=axios) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/axios?style=flat-square)](https://bundlephobia.com/package/axios@latest) | ||
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://npm-stat.com/charts.html?package=axios) | ||
[![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios) | ||
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios) | ||
[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) | ||
@@ -28,7 +14,6 @@ [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios) | ||
Promise based HTTP client for the browser and node.js | ||
> New axios docs website: [click here](https://axios-http.com/) | ||
</div> | ||
## Table of Contents | ||
@@ -39,4 +24,2 @@ | ||
- [Installing](#installing) | ||
- [Package manager](#package-manager) | ||
- [CDN](#cdn) | ||
- [Example](#example) | ||
@@ -61,12 +44,8 @@ - [Axios API](#axios-api) | ||
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format) | ||
- [URLSearchParams](#urlsearchparams) | ||
- [Query string](#query-string-older-browsers) | ||
- [π Automatic serialization](#-automatic-serialization-to-urlsearchparams) | ||
- [Using multipart/form-data format](#using-multipartform-data-format) | ||
- [FormData](#formdata) | ||
- [π Automatic serialization](#-automatic-serialization-to-formdata) | ||
- [Files Posting](#files-posting) | ||
- [HTML Form Posting](#-html-form-posting-browser) | ||
- [π Progress capturing](#-progress-capturing) | ||
- [π Rate limiting](#-progress-capturing) | ||
- [Browser](#browser) | ||
- [Node.js](#nodejs) | ||
- [Query string](#query-string) | ||
- [Form data](#form-data) | ||
- [Automatic serialization](#-automatic-serialization) | ||
- [Manual FormData passing](#manual-formdata-passing) | ||
- [Semver](#semver) | ||
@@ -82,3 +61,3 @@ - [Promises](#promises) | ||
- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser | ||
- Make [http](https://nodejs.org/api/http.html) requests from node.js | ||
- Make [http](http://nodejs.org/api/http.html) requests from node.js | ||
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API | ||
@@ -88,9 +67,8 @@ - Intercept request and response | ||
- Cancel requests | ||
- Automatic transforms for [JSON](https://www.json.org/json-en.html) data | ||
- π Automatic data object serialization to `multipart/form-data` and `x-www-form-urlencoded` body encodings | ||
- Client side support for protecting against [XSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery) | ||
- Automatic transforms for JSON data | ||
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) | ||
## Browser Support | ||
![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | | ||
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | | ||
--- | --- | --- | --- | --- | --- | | ||
@@ -103,4 +81,2 @@ Latest β | Latest β | Latest β | Latest β | Latest β | 11 β | | ||
### Package manager | ||
Using npm: | ||
@@ -124,61 +100,30 @@ | ||
Using pnpm: | ||
Using jsDelivr CDN: | ||
```bash | ||
$ pnpm add axios | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | ||
``` | ||
Once the package is installed, you can import the library using `import` or `require` approach: | ||
Using unpkg CDN: | ||
```js | ||
import axios, {isCancel, AxiosError} from 'axios'; | ||
```html | ||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
``` | ||
You can also use the default export, since the named export is just a re-export from the Axios factory: | ||
## Example | ||
```js | ||
import axios from 'axios'; | ||
### note: CommonJS usage | ||
In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach: | ||
console.log(axios.isCancel('something')); | ||
```` | ||
If you use `require` for importing, **only default export is available**: | ||
```js | ||
const axios = require('axios'); | ||
const axios = require('axios').default; | ||
console.log(axios.isCancel('something')); | ||
// axios.<method> will now provide autocomplete and parameter typings | ||
``` | ||
For cases where something went wrong when trying to import a module into a custom or legacy environment, | ||
you can try importing the module package directly: | ||
Performing a `GET` request | ||
```js | ||
const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017) | ||
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017) | ||
``` | ||
const axios = require('axios').default; | ||
### CDN | ||
Using jsDelivr CDN (ES5 UMD browser module): | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script> | ||
``` | ||
Using unpkg CDN: | ||
```html | ||
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script> | ||
``` | ||
## Example | ||
> **Note** CommonJS usage | ||
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach: | ||
```js | ||
import axios from 'axios'; | ||
//const axios = require('axios'); // legacy way | ||
// Make a request for a user with a given ID | ||
@@ -194,3 +139,3 @@ axios.get('/user?ID=12345') | ||
}) | ||
.finally(function () { | ||
.then(function () { | ||
// always executed | ||
@@ -211,5 +156,5 @@ }); | ||
}) | ||
.finally(function () { | ||
.then(function () { | ||
// always executed | ||
}); | ||
}); | ||
@@ -227,3 +172,3 @@ // Want to use async/await? Add the `async` keyword to your outer function/method. | ||
> **Note** `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
> Explorer and older browsers, so use with caution. | ||
@@ -286,3 +231,3 @@ | ||
method: 'get', | ||
url: 'https://bit.ly/2mTM3nY', | ||
url: 'http://bit.ly/2mTM3nY', | ||
responseType: 'stream' | ||
@@ -399,7 +344,6 @@ }) | ||
// `paramsSerializer` is an optional config in charge of serializing `params` | ||
paramsSerializer: { | ||
encode?: (param: string): string => { /* Do custom ops here and return transformed string */ }, // custom encoder function; sends Key/Values in an iterative fashion | ||
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), // mimic pre 1.x behavior and send entire params object to a custom serializer func. Allows consumer to control how params are serialized. | ||
indexes: false // array indexes format (null - no brackets, false (default) - empty brackets, true - brackets with indexes) | ||
// `paramsSerializer` is an optional function in charge of serializing `params` | ||
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) | ||
paramsSerializer: function (params) { | ||
return Qs.stringify(params, {arrayFormat: 'brackets'}) | ||
}, | ||
@@ -412,7 +356,7 @@ | ||
// - Browser only: FormData, File, Blob | ||
// - Node only: Stream, Buffer, FormData (form-data package) | ||
// - Node only: Stream, Buffer | ||
data: { | ||
firstName: 'Fred' | ||
}, | ||
// syntax alternative to send data into the body | ||
@@ -463,11 +407,11 @@ // method post | ||
// `onUploadProgress` allows handling of progress events for uploads | ||
// browser & node.js | ||
onUploadProgress: function ({loaded, total, progress, bytes, estimated, rate, upload = true}) { | ||
// Do whatever you want with the Axios progress event | ||
// browser only | ||
onUploadProgress: function (progressEvent) { | ||
// Do whatever you want with the native progress event | ||
}, | ||
// `onDownloadProgress` allows handling of progress events for downloads | ||
// browser & node.js | ||
onDownloadProgress: function ({loaded, total, progress, bytes, estimated, rate, download = true}) { | ||
// Do whatever you want with the Axios progress event | ||
// browser only | ||
onDownloadProgress: function (progressEvent) { | ||
// Do whatever you want with the native progress event | ||
}, | ||
@@ -502,3 +446,3 @@ | ||
} | ||
}, | ||
}; | ||
@@ -510,5 +454,2 @@ // `socketPath` defines a UNIX Socket to be used in node.js. | ||
socketPath: null, // default | ||
// `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects. | ||
transport: undefined, // default | ||
@@ -531,7 +472,6 @@ // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http | ||
// `Proxy-Authorization` custom headers you have set using `headers`. | ||
// If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
// If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
proxy: { | ||
protocol: 'https', | ||
host: '127.0.0.1', | ||
// hostname: '127.0.0.1' // Takes precedence over 'host' if both are defined | ||
port: 9000, | ||
@@ -552,4 +492,4 @@ auth: { | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// from the responses objects of all decompressed responses | ||
@@ -576,3 +516,3 @@ // - Node only (XHR cannot turn off decompression) | ||
forcedJSONParsing: true, | ||
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | ||
@@ -585,16 +525,3 @@ clarifyTimeoutError: false, | ||
FormData: window?.FormData || global?.FormData | ||
}, | ||
formSerializer: { | ||
visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values | ||
dots: boolean; // use dots instead of brackets format | ||
metaTokens: boolean; // keep special endings like {} in parameter key | ||
indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes | ||
}, | ||
// http adapter only (node.js) | ||
maxRate: [ | ||
100 * 1024, // 100KB/s upload limit, | ||
100 * 1024 // 100KB/s download limit | ||
] | ||
} | ||
} | ||
@@ -619,3 +546,3 @@ ``` | ||
// `headers` the HTTP headers that the server responded with | ||
// All header names are lowercase and can be accessed using the bracket notation. | ||
// All header names are lower cased and can be accessed using the bracket notation. | ||
// Example: `response.headers['content-type']` | ||
@@ -679,3 +606,3 @@ headers: {}, | ||
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults/index.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. | ||
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. | ||
@@ -730,11 +657,2 @@ ```js | ||
You can also clear all interceptors for requests or responses. | ||
```js | ||
const instance = axios.create(); | ||
instance.interceptors.request.use(function () {/*...*/}); | ||
instance.interceptors.request.clear(); // Removes interceptors from requests | ||
instance.interceptors.response.use(function () {/*...*/}); | ||
instance.interceptors.response.clear(); // Removes interceptors from responses | ||
``` | ||
You can add interceptors to a custom instance of axios. | ||
@@ -748,3 +666,3 @@ | ||
When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay | ||
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
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 | ||
@@ -760,3 +678,3 @@ to the options object that will tell axios to run the code synchronously and avoid any delays in request execution. | ||
If you want to execute a particular interceptor based on a runtime check, | ||
If you want to execute a particular interceptor based on a runtime check, | ||
you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return | ||
@@ -784,3 +702,3 @@ of `runWhen` is `false`. The function will be called with the config | ||
- then only the last interceptor's result is returned | ||
- then every interceptor receives the result of its predecessor | ||
- then every interceptor receives the result of it's predecessor | ||
- and when the fulfillment-interceptor throws | ||
@@ -790,3 +708,3 @@ - then the following fulfillment-interceptor is not called | ||
- once caught, another following fulfill-interceptor is called again (just like in a promise chain). | ||
Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code. | ||
@@ -796,4 +714,2 @@ | ||
the default behavior is to reject every response that returns with a status code that falls out of the range of 2xx and treat it as an error. | ||
```js | ||
@@ -821,3 +737,3 @@ axios.get('/user/12345') | ||
Using the `validateStatus` config option, you can override the default condition (status >= 200 && status < 300) and define HTTP code(s) that should throw an error. | ||
Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error. | ||
@@ -863,3 +779,3 @@ ```js | ||
> The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
@@ -911,23 +827,24 @@ > This API is deprecated since v0.22.0 and shouldn't be used in new projects | ||
> **Note:** you can cancel several requests with the same cancel token/abort controller. | ||
> 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 a real request. | ||
> Note: you can cancel several requests with the same cancel token/abort controller. | ||
> 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. | ||
> During the transition period, you can use both cancellation APIs, even for the same request: | ||
## Using `application/x-www-form-urlencoded` format | ||
## Using application/x-www-form-urlencoded format | ||
### URLSearchParams | ||
By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following options. | ||
By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers,and [ Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018). | ||
### Browser | ||
In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: | ||
```js | ||
const params = new URLSearchParams({ foo: 'bar' }); | ||
params.append('extraparam', 'value'); | ||
const params = new URLSearchParams(); | ||
params.append('param1', 'value1'); | ||
params.append('param2', 'value2'); | ||
axios.post('/foo', params); | ||
``` | ||
### Query string (Older browsers) | ||
> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). | ||
For compatibility with very old browsers, there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). | ||
Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: | ||
@@ -954,95 +871,31 @@ | ||
### Older Node.js versions | ||
### Node.js | ||
For older Node.js engines, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
#### Query string | ||
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
```js | ||
const querystring = require('querystring'); | ||
axios.post('https://something.com/', querystring.stringify({ foo: 'bar' })); | ||
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); | ||
``` | ||
You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows: | ||
> **Note** | ||
> The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case. | ||
### π Automatic serialization to URLSearchParams | ||
Axios will automatically serialize the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded". | ||
```js | ||
const data = { | ||
x: 1, | ||
arr: [1, 2, 3], | ||
arr2: [1, [2], 3], | ||
users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], | ||
}; | ||
await axios.postForm('https://postman-echo.com/post', data, | ||
{headers: {'content-type': 'application/x-www-form-urlencoded'}} | ||
); | ||
const url = require('url'); | ||
const params = new url.URLSearchParams({ foo: 'bar' }); | ||
axios.post('http://something.com/', params.toString()); | ||
``` | ||
The server will handle it as: | ||
You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
```js | ||
{ | ||
x: '1', | ||
'arr[]': [ '1', '2', '3' ], | ||
'arr2[0]': '1', | ||
'arr2[1][0]': '2', | ||
'arr2[2]': '3', | ||
'arr3[]': [ '1', '2', '3' ], | ||
'users[0][name]': 'Peter', | ||
'users[0][surname]': 'griffin', | ||
'users[1][name]': 'Thomas', | ||
'users[1][surname]': 'Anderson' | ||
} | ||
```` | ||
> NOTE: | ||
> The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case. | ||
If your backend body-parser (like `body-parser` of `express.js`) supports nested objects decoding, you will get the same object on the server-side automatically | ||
#### Form data | ||
```js | ||
var app = express(); | ||
##### π Automatic serialization | ||
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies | ||
app.post('/', function (req, res, next) { | ||
// echo body as JSON | ||
res.send(JSON.stringify(req.body)); | ||
}); | ||
server = app.listen(3000); | ||
``` | ||
## Using `multipart/form-data` format | ||
### FormData | ||
To send the data as a `multipart/formdata` you need to pass a formData instance as a payload. | ||
Setting the `Content-Type` header is not required as Axios guesses it based on the payload type. | ||
```js | ||
const formData = new FormData(); | ||
formData.append('foo', 'bar'); | ||
axios.post('https://httpbin.org/post', formData); | ||
``` | ||
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: | ||
```js | ||
const FormData = require('form-data'); | ||
const form = new FormData(); | ||
form.append('my_field', 'my value'); | ||
form.append('my_buffer', new Buffer(10)); | ||
form.append('my_file', fs.createReadStream('/foo/bar.jpg')); | ||
axios.post('https://example.com', form) | ||
``` | ||
### π Automatic serialization to FormData | ||
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type` | ||
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type` | ||
header is set to `multipart/form-data`. | ||
@@ -1059,3 +912,3 @@ | ||
} | ||
}).then(({data}) => console.log(data)); | ||
}).then(({data})=> console.log(data)); | ||
``` | ||
@@ -1069,3 +922,3 @@ | ||
```js | ||
const axios = require('axios'); | ||
const axios= require('axios'); | ||
var FormData = require('form-data'); | ||
@@ -1077,3 +930,3 @@ | ||
} | ||
}).then(({data}) => console.log(data)); | ||
}).then(({data})=> console.log(data)); | ||
``` | ||
@@ -1084,213 +937,43 @@ | ||
- `{}` - serialize the value with JSON.stringify | ||
- `[]` - unwrap the array-like object as separate fields with the same key | ||
- `[]` - unwrap the array like object as separate fields with the same key | ||
> **Note** | ||
> unwrap/expand operation will be used by default on arrays and FileList objects | ||
FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases: | ||
- `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object | ||
to a `FormData` object by following custom rules. | ||
- `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects; | ||
- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. | ||
The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON. | ||
- `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects | ||
- `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) | ||
- `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) | ||
- `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) | ||
Let's say we have an object like this one: | ||
```js | ||
const obj = { | ||
x: 1, | ||
arr: [1, 2, 3], | ||
arr2: [1, [2], 3], | ||
users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], | ||
'obj2{}': [{x:1}] | ||
}; | ||
``` | ||
const axios= require('axios'); | ||
The following steps will be executed by the Axios serializer internally: | ||
```js | ||
const formData = new FormData(); | ||
formData.append('x', '1'); | ||
formData.append('arr[]', '1'); | ||
formData.append('arr[]', '2'); | ||
formData.append('arr[]', '3'); | ||
formData.append('arr2[0]', '1'); | ||
formData.append('arr2[1][0]', '2'); | ||
formData.append('arr2[2]', '3'); | ||
formData.append('users[0][name]', 'Peter'); | ||
formData.append('users[0][surname]', 'Griffin'); | ||
formData.append('users[1][name]', 'Thomas'); | ||
formData.append('users[1][surname]', 'Anderson'); | ||
formData.append('obj2{}', '[{"x":1}]'); | ||
axios.post('https://httpbin.org/post', { | ||
'myObj{}': {x: 1, s: "foo"}, | ||
'files[]': document.querySelector('#fileInput').files | ||
}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}).then(({data})=> console.log(data)); | ||
``` | ||
Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm` | ||
which are just the corresponding http methods with the `Content-Type` header preset to `multipart/form-data`. | ||
which are just the corresponding http methods with a header preset: `Content-Type`: `multipart/form-data`. | ||
## Files Posting | ||
FileList object can be passed directly: | ||
You can easily submit a single file: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', { | ||
'myVar' : 'foo', | ||
'file': document.querySelector('#fileInput').files[0] | ||
}); | ||
``` | ||
or multiple files as `multipart/form-data`: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', { | ||
'files[]': document.querySelector('#fileInput').files | ||
}); | ||
``` | ||
`FileList` object can be passed directly: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files) | ||
``` | ||
All files will be sent with the same field names: `files[]`. | ||
All files will be sent with the same field names: `files[]`; | ||
## π HTML Form Posting (browser) | ||
##### Manual FormData passing | ||
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: | ||
Pass HTML Form element as a payload to submit it as `multipart/form-data` content. | ||
```js | ||
await axios.postForm('https://httpbin.org/post', document.querySelector('#htmlForm')); | ||
``` | ||
const FormData = require('form-data'); | ||
const form = new FormData(); | ||
form.append('my_field', 'my value'); | ||
form.append('my_buffer', new Buffer(10)); | ||
form.append('my_file', fs.createReadStream('/foo/bar.jpg')); | ||
`FormData` and `HTMLForm` objects can also be posted as `JSON` by explicitly setting the `Content-Type` header to `application/json`: | ||
```js | ||
await axios.post('https://httpbin.org/post', document.querySelector('#htmlForm'), { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}) | ||
axios.post('https://example.com', form) | ||
``` | ||
For example, the Form | ||
```html | ||
<form id="form"> | ||
<input type="text" name="foo" value="1"> | ||
<input type="text" name="deep.prop" value="2"> | ||
<input type="text" name="deep prop spaced" value="3"> | ||
<input type="text" name="baz" value="4"> | ||
<input type="text" name="baz" value="5"> | ||
<select name="user.age"> | ||
<option value="value1">Value 1</option> | ||
<option value="value2" selected>Value 2</option> | ||
<option value="value3">Value 3</option> | ||
</select> | ||
<input type="submit" value="Save"> | ||
</form> | ||
``` | ||
will be submitted as the following JSON object: | ||
```js | ||
{ | ||
"foo": "1", | ||
"deep": { | ||
"prop": { | ||
"spaced": "3" | ||
} | ||
}, | ||
"baz": [ | ||
"4", | ||
"5" | ||
], | ||
"user": { | ||
"age": "value2" | ||
} | ||
} | ||
```` | ||
Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported. | ||
## π Progress capturing | ||
Axios supports both browser and node environments to capture request upload/download progress. | ||
```js | ||
await axios.post(url, data, { | ||
onUploadProgress: function (axiosProgressEvent) { | ||
/*{ | ||
loaded: number; | ||
total?: number; | ||
progress?: number; // in range [0..1] | ||
bytes: number; // how many bytes have been transferred since the last trigger (delta) | ||
estimated?: number; // estimated time in seconds | ||
rate?: number; // upload speed in bytes | ||
upload: true; // upload sign | ||
}*/ | ||
}, | ||
onDownloadProgress: function (axiosProgressEvent) { | ||
/*{ | ||
loaded: number; | ||
total?: number; | ||
progress?: number; | ||
bytes: number; | ||
estimated?: number; | ||
rate?: number; // download speed in bytes | ||
download: true; // download sign | ||
}*/ | ||
} | ||
}); | ||
``` | ||
You can also track stream upload/download progress in node.js: | ||
```js | ||
const {data} = await axios.post(SERVER_URL, readableStream, { | ||
onUploadProgress: ({progress}) => { | ||
console.log((progress * 100).toFixed(2)); | ||
}, | ||
headers: { | ||
'Content-Length': contentLength | ||
}, | ||
maxRedirects: 0 // avoid buffering the entire stream | ||
}); | ||
```` | ||
> **Note:** | ||
> Capturing FormData upload progress is currently not currently supported in node.js environments. | ||
> **β οΈ Warning** | ||
> It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment, | ||
> as follow-redirects package will buffer the entire stream in RAM without following the "backpressure" algorithm. | ||
## π Rate limiting | ||
Download and upload rate limits can only be set for the http adapter (node.js): | ||
```js | ||
const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, { | ||
onUploadProgress: ({progress, rate}) => { | ||
console.log(`Upload [${(progress*100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`) | ||
}, | ||
maxRate: [100 * 1024], // 100KB/s limit | ||
}); | ||
``` | ||
## Semver | ||
@@ -1302,3 +985,3 @@ | ||
axios depends on a native ES6 Promise implementation to be [supported](https://caniuse.com/promises). | ||
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). | ||
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). | ||
@@ -1308,3 +991,3 @@ | ||
axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors. | ||
axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors. | ||
@@ -1325,13 +1008,7 @@ ```typescript | ||
Because axios dual publishes with an ESM default export and a CJS `module.exports`, there are some caveats. | ||
The recommended setting is to use `"moduleResolution": "node16"` (this is implied by `"module": "node16"`). Note that this requires TypeScript 4.7 or greater. | ||
If use ESM, your settings should be fine. | ||
If you compile TypeScript to CJS and you canβt use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`. | ||
If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`. | ||
## Online one-click setup | ||
You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online. | ||
You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online. | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js) | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js) | ||
@@ -1341,6 +1018,7 @@ | ||
* [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) | ||
* [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md) | ||
* [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md) | ||
* [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md) | ||
* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) | ||
* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md) | ||
* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) | ||
* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md) | ||
* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) | ||
@@ -1347,0 +1025,0 @@ ## Credits |
@@ -1,6 +0,5 @@ | ||
# Reporting a Vulnerability | ||
# Security Policy | ||
If you discover a security vulnerability in axios please disclose it via [our huntr page](https://huntr.dev/repos/axios/axios/). Bounty eligibility, CVE assignment, response times and past reports are all there. | ||
## Reporting a Vulnerability | ||
Thank you for improving the security of axios. | ||
Please report security issues to jasonsaayman@gmail.com |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
35
2
445714
52
4660
1
992
4
No
- Removedproxy-from-env@^1.1.0
- Removedproxy-from-env@1.1.0(transitive)
Updatedfollow-redirects@^1.14.9