Comparing version 0.21.3 to 1.6.0
1231
CHANGELOG.md
# Changelog | ||
### 0.21.3 (September 4, 2021) | ||
# [1.6.0](https://github.com/axios/axios/compare/v1.5.1...v1.6.0) (2023-10-26) | ||
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) | ||
* **CSRF:** fixed CSRF vulnerability CVE-2023-45857 ([#6028](https://github.com/axios/axios/issues/6028)) ([96ee232](https://github.com/axios/axios/commit/96ee232bd3ee4de2e657333d4d2191cd389e14d0)) | ||
* **dns:** fixed lookup function decorator to work properly in node v20; ([#6011](https://github.com/axios/axios/issues/6011)) ([5aaff53](https://github.com/axios/axios/commit/5aaff532a6b820bb9ab6a8cd0f77131b47e2adb8)) | ||
* **types:** fix AxiosHeaders types; ([#5931](https://github.com/axios/axios/issues/5931)) ([a1c8ad0](https://github.com/axios/axios/commit/a1c8ad008b3c13d53e135bbd0862587fb9d3fc09)) | ||
### 0.21.2 (September 4, 2021) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
Fixes and Functionality: | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- 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)) | ||
### Contributors to this release | ||
Internal and Tests: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+449/-114 (#6032 #6021 #6011 #5932 #5931 )") | ||
- <img src="https://avatars.githubusercontent.com/u/63700910?v=4&s=18" alt="avatar" width="18"/> [Valentin Panov](https://github.com/valentin-panov "+4/-4 (#6028 )") | ||
- <img src="https://avatars.githubusercontent.com/u/76877078?v=4&s=18" alt="avatar" width="18"/> [Rinku Chaudhari](https://github.com/therealrinku "+1/-1 (#5889 )") | ||
- Updating build dev dependancies ([#3401](https://github.com/axios/axios/pull/3401)) | ||
- Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538)) | ||
- Updating follow rediect 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)) | ||
## [1.5.1](https://github.com/axios/axios/compare/v1.5.0...v1.5.1) (2023-09-26) | ||
Documentation: | ||
- 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 gramatical errors ([#2642](https://github.com/axios/axios/pull/2642)) | ||
- Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567)) | ||
- Moving gitpod metion ([#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)) | ||
### Bug Fixes | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
* **adapters:** improved adapters loading logic to have clear error messages; ([#5919](https://github.com/axios/axios/issues/5919)) ([e410779](https://github.com/axios/axios/commit/e4107797a7a1376f6209fbecfbbce73d3faa7859)) | ||
* **formdata:** fixed automatic addition of the `Content-Type` header for FormData in non-browser environments; ([#5917](https://github.com/axios/axios/issues/5917)) ([bc9af51](https://github.com/axios/axios/commit/bc9af51b1886d1b3529617702f2a21a6c0ed5d92)) | ||
* **headers:** allow `content-encoding` header to handle case-insensitive values ([#5890](https://github.com/axios/axios/issues/5890)) ([#5892](https://github.com/axios/axios/issues/5892)) ([4c89f25](https://github.com/axios/axios/commit/4c89f25196525e90a6e75eda9cb31ae0a2e18acd)) | ||
* **types:** removed duplicated code ([9e62056](https://github.com/axios/axios/commit/9e6205630e1c9cf863adf141c0edb9e6d8d4b149)) | ||
- [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) | ||
### Contributors to this release | ||
### 0.21.1 (December 21, 2020) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+89/-18 (#5919 #5917 )") | ||
- <img src="https://avatars.githubusercontent.com/u/110460234?v=4&s=18" alt="avatar" width="18"/> [David Dallas](https://github.com/DavidJDallas "+11/-5 ()") | ||
- <img src="https://avatars.githubusercontent.com/u/71556073?v=4&s=18" alt="avatar" width="18"/> [Sean Sattler](https://github.com/fb-sean "+2/-8 ()") | ||
- <img src="https://avatars.githubusercontent.com/u/4294069?v=4&s=18" alt="avatar" width="18"/> [Mustafa AteΕ Uzun](https://github.com/0o001 "+4/-4 ()") | ||
- <img src="https://avatars.githubusercontent.com/u/132928043?v=4&s=18" alt="avatar" width="18"/> [Przemyslaw Motacki](https://github.com/sfc-gh-pmotacki "+2/-1 (#5892 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+1/-1 ()") | ||
Fixes and Functionality: | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- 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)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
Internal and Tests: | ||
# [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26) | ||
- 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)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Bug Fixes | ||
- 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> | ||
* **adapter:** make adapter loading error more clear by using platform-specific adapters explicitly ([#5837](https://github.com/axios/axios/issues/5837)) ([9a414bb](https://github.com/axios/axios/commit/9a414bb6c81796a95c6c7fe668637825458e8b6d)) | ||
* **dns:** fixed `cacheable-lookup` integration; ([#5836](https://github.com/axios/axios/issues/5836)) ([b3e327d](https://github.com/axios/axios/commit/b3e327dcc9277bdce34c7ef57beedf644b00d628)) | ||
* **headers:** added support for setting header names that overlap with class methods; ([#5831](https://github.com/axios/axios/issues/5831)) ([d8b4ca0](https://github.com/axios/axios/commit/d8b4ca0ea5f2f05efa4edfe1e7684593f9f68273)) | ||
* **headers:** fixed common Content-Type header merging; ([#5832](https://github.com/axios/axios/issues/5832)) ([8fda276](https://github.com/axios/axios/commit/8fda2766b1e6bcb72c3fabc146223083ef13ce17)) | ||
### 0.21.0 (October 23, 2020) | ||
Fixes and Functionality: | ||
### Features | ||
- 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)) | ||
* export getAdapter function ([#5324](https://github.com/axios/axios/issues/5324)) ([ca73eb8](https://github.com/axios/axios/commit/ca73eb878df0ae2dace81fe3a7f1fb5986231bf1)) | ||
* **export:** export adapters without `unsafe` prefix ([#5839](https://github.com/axios/axios/issues/5839)) ([1601f4a](https://github.com/axios/axios/commit/1601f4a27a81ab47fea228f1e244b2c4e3ce28bf)) | ||
Internal and Tests: | ||
### Contributors to this release | ||
- Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+66/-29 (#5839 #5837 #5836 #5832 #5831 )") | ||
- <img src="https://avatars.githubusercontent.com/u/102841186?v=4&s=18" alt="avatar" width="18"/> [ε€θ¬](https://github.com/geekact "+42/-0 (#5324 )") | ||
- <img src="https://avatars.githubusercontent.com/u/65978976?v=4&s=18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )") | ||
Documentation: | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252)) | ||
- Fixing typos ([#3309](https://github.com/axios/axios/pull/3309)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
# [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27) | ||
- 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. | ||
* **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)) | ||
### 0.20.0-pre (July 15, 2020) | ||
Fixes and Functionality: | ||
### Features | ||
- 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)) | ||
* **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)) | ||
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)) | ||
### Performance Improvements | ||
Documentation: | ||
* **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)) | ||
- 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: | ||
- <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 )") | ||
- 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> | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.19.2 (Jan 20, 2020) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion) | ||
## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19) | ||
### 0.19.1 (Jan 7, 2020) | ||
Fixes and Functionality: | ||
### Bug Fixes | ||
- 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)) | ||
* **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)) | ||
Internal: | ||
### Contributors to this release | ||
- 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)) | ||
- <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 )") | ||
Documentation: | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- 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)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.19.0 (May 30, 2019) | ||
## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05) | ||
Fixes and Functionality: | ||
- 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 | ||
### Bug Fixes | ||
Internal: | ||
* **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)) | ||
- 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 | ||
### Contributors to this release | ||
Documentation: | ||
- <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 )") | ||
- 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 | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.19.0-beta.1 (Aug 9, 2018) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
**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. | ||
## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22) | ||
New Functionality: | ||
- 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) | ||
### Bug Fixes | ||
Fixes: | ||
* **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)) | ||
- 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 | ||
### 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: | ||
- <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 )") | ||
- 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> | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.18.0 (Feb 19, 2018) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- 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)) | ||
## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13) | ||
### 0.17.1 (Nov 11, 2017) | ||
- 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)) | ||
### Bug Fixes | ||
### 0.17.0 (Oct 21, 2017) | ||
* **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)) | ||
- **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)) | ||
### Contributors to this release | ||
### 0.16.2 (Jun 3, 2017) | ||
- <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 )") | ||
- 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)) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.16.1 (Apr 8, 2017) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- 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)) | ||
## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03) | ||
### 0.16.0 (Mar 31, 2017) | ||
- **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)) | ||
### Bug Fixes | ||
### 0.15.3 (Nov 27, 2016) | ||
* **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)) | ||
- 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) | ||
- <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 )") | ||
- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482)) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.15.1 (Oct 14, 2016) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485)) | ||
## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01) | ||
### 0.15.0 (Oct 10, 2016) | ||
- 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)) | ||
### Bug Fixes | ||
### 0.14.0 (Aug 27, 2016) | ||
* **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)) | ||
- **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)) | ||
### Contributors to this release | ||
### 0.13.1 (Jul 16, 2016) | ||
- <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 )") | ||
- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378)) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.13.0 (Jul 13, 2016) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- **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)) | ||
# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31) | ||
### 0.12.0 (May 31, 2016) | ||
- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317)) | ||
- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307)) | ||
### Bug Fixes | ||
### 0.11.1 (May 17, 2016) | ||
* **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)) | ||
- 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)) | ||
### 0.11.0 (Apr 26, 2016) | ||
### Features | ||
- 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)) | ||
* **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.10.0 (Apr 20, 2016) | ||
### Contributors to this release | ||
- 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)) | ||
- <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 )") | ||
### 0.9.1 (Jan 24, 2016) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- 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)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.9.0 (Jan 18, 2016) | ||
## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28) | ||
- 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) | ||
### Bug Fixes | ||
- 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)) | ||
* **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)) | ||
### 0.8.0 (Dec 11, 2015) | ||
### Contributors to this release | ||
- 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)) | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )") | ||
### 0.7.0 (Sep 29, 2015) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- 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)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.6.0 (Sep 21, 2015) | ||
## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26) | ||
- 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) | ||
### Bug Fixes | ||
- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53)) | ||
* **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)) | ||
### 0.5.3 (Apr 07, 2015) | ||
### Contributors to this release | ||
- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55)) | ||
- ![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 )") | ||
### 0.5.2 (Mar 13, 2015) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.5.1 (Mar 10, 2015) | ||
## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22) | ||
- 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) | ||
### Bug Fixes | ||
- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14)) | ||
- Updating es6-promise dependency | ||
* **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.4.2 (Dec 10, 2014) | ||
### Contributors to this release | ||
- 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)) | ||
- ![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 )") | ||
### 0.4.1 (Oct 15, 2014) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.4.0 (Oct 03, 2014) | ||
## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10) | ||
- 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) | ||
### Bug Fixes | ||
- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3)) | ||
* **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)) | ||
### 0.3.0 (Sep 16, 2014) | ||
### Contributors to this release | ||
- 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)) | ||
- ![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 )") | ||
### 0.2.2 (Sep 14, 2014) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4)) | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.2.1 (Sep 12, 2014) | ||
## [1.2.2] - 2022-12-29 | ||
- Fixing build problem causing ridiculous file sizes | ||
### 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) | ||
### 0.2.0 (Sep 12, 2014) | ||
### 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) | ||
- Adding support for `all` and `spread` | ||
- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1)) | ||
### 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) | ||
### 0.1.0 (Aug 29, 2014) | ||
## [1.2.1] - 2022-12-05 | ||
- Initial release | ||
### Changed | ||
- feat(exports): export mergeConfig [#5151](https://github.com/axios/axios/pull/5151) | ||
### 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) | ||
### 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) | ||
### 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) | ||
### Contributors to this release | ||
- [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) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.2.0] - 2022-11-10 | ||
### Changed | ||
- 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) | ||
### Fixed | ||
- 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) | ||
### Refactors | ||
- refactor: allowing adapters to be loaded by name [#5277](https://github.com/axios/axios/pull/5277) | ||
### Chores | ||
- 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) | ||
### Contributors to this release | ||
- [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) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.3] - 2022-10-15 | ||
### Added | ||
- Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113) | ||
### Fixed | ||
- 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) | ||
### Chores | ||
- 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) | ||
### Contributors to this release | ||
- [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) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.2] - 2022-10-07 | ||
### Fixed | ||
- Fixed broken exports for UMD builds. | ||
### Contributors to this release | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.1] - 2022-10-07 | ||
### Fixed | ||
- 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. | ||
### Contributors to this release | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.0] - 2022-10-06 | ||
### Fixed | ||
- 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) | ||
### Contributors to this release | ||
- [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) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
β οΈ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.0.0] - 2022-10-04 | ||
### Added | ||
- 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) | ||
### Changed | ||
- 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) | ||
### 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. | ||
### Removed | ||
- 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) | ||
### Fixed | ||
- 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) | ||
### 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) | ||
### Security | ||
- Update SECURITY.md [#4687](https://github.com/axios/axios/pull/4687) | ||
### Contributors to this release | ||
- [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) |
@@ -1,3 +0,2 @@ | ||
/* axios v0.21.3 | (c) 2021 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()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=10)}([function(e,t,r){"use strict";var n=r(2),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function r(r,n){u(t[n])&&u(r)?t[n]=e(t[n],r):u(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)f(arguments[n],r);return t},extend:function(e,t,r){return f(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):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}}},function(e,t,r){"use strict";var n=r(0),o=r(16),i=r(4),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,c={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(u=r(5)),u),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),JSON.stringify(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!r&&"json"===this.responseType;if(s||o&&n.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(s)})),e.exports=c},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},function(e,t,r){"use strict";var n=r(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,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var s=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.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,r){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.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}},e}},function(e,t,r){"use strict";var n=r(0),o=r(17),i=r(18),s=r(3),a=r(19),u=r(22),c=r(23),f=r(6);e.exports=function(e){return new Promise((function(t,r){var p=e.data,l=e.headers,d=e.responseType;n.isFormData(p)&&delete l["Content-Type"];var h=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",g=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";l.Authorization="Basic "+btoa(m+":"+g)}var v=a(e.baseURL,e.url);function y(){if(h){var n="getAllResponseHeaders"in h?u(h.getAllResponseHeaders()):null,i={data:d&&"text"!==d&&"json"!==d?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:n,config:e,request:h};o(t,r,i),h=null}}if(h.open(e.method.toUpperCase(),s(v,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,"onloadend"in h?h.onloadend=y:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))&&setTimeout(y)},h.onabort=function(){h&&(r(f("Request aborted",e,"ECONNABORTED",h)),h=null)},h.onerror=function(){r(f("Network Error",e,null,h)),h=null},h.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(f(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",h)),h=null},n.isStandardBrowserEnv()){var b=(e.withCredentials||c(v))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;b&&(l[e.xsrfHeaderName]=b)}"setRequestHeader"in h&&n.forEach(l,(function(e,t){void 0===p&&"content-type"===t.toLowerCase()?delete l[t]:h.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(h.withCredentials=!!e.withCredentials),d&&"json"!==d&&(h.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){h&&(h.abort(),r(e),h=null)})),p||(p=null),h.send(p)}))}},function(e,t,r){"use strict";var n=r(4);e.exports=function(e,t,r,o,i){var s=new Error(e);return n(s,t,r,o,i)}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function u(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function c(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=u(void 0,t[e]))})),n.forEach(i,c),n.forEach(s,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=u(e[n],t[n]):n in e&&(r[n]=u(void 0,e[n]))}));var f=o.concat(i).concat(s).concat(a),p=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===f.indexOf(e)}));return n.forEach(p,c),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){e.exports=r(11)},function(e,t,r){"use strict";var n=r(0),o=r(2),i=r(12),s=r(8);function a(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var u=a(r(1));u.Axios=i,u.create=function(e){return a(s(u.defaults,e))},u.Cancel=r(9),u.CancelToken=r(26),u.isCancel=r(7),u.all=function(e){return Promise.all(e)},u.spread=r(27),u.isAxiosError=r(28),e.exports=u,e.exports.default=u},function(e,t,r){"use strict";var n=r(0),o=r(3),i=r(13),s=r(14),a=r(8),u=r(24),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!n){var f=[s,void 0];for(Array.prototype.unshift.apply(f,r),f=f.concat(i),o=Promise.resolve(e);f.length;)o=o.then(f.shift(),f.shift());return o}for(var p=e;r.length;){var l=r.shift(),d=r.shift();try{p=l(p)}catch(e){d(e);break}}try{o=s(p)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=f},function(e,t,r){"use strict";var n=r(0);function o(){this.handlers=[]}o.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,r){"use strict";var n=r(0),o=r(15),i=r(7),s=r(1);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return a(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(a(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(0),o=r(1);e.exports=function(e,t,r){var i=this||o;return n.forEach(r,(function(r){e=r.call(i,e,t)})),e}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(6);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.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,r){"use strict";var n=r(20),o=r(21);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(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,r,i,s={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}})),s):s}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(25),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={},s=n.version.split(".");function a(e,t){for(var r=t?t.split("."):s,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}o.transitional=function(e,t,r){var o=t&&a(t);function s(e,t){return"[Axios v"+n.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,a){if(!1===e)throw new Error(s(n," has been removed in "+t));return o&&!i[n]&&(i[n]=!0,console.warn(s(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,a)}},e.exports={isOlderVersion:a,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+i)}},validators:o}},function(e){e.exports=JSON.parse('{"name":"axios","version":"0.21.3","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')},function(e,t,r){"use strict";var n=r(9);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 r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}}])})); | ||
//# sourceMappingURL=axios.min.map | ||
!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 v=d("string"),y=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 C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,N=function(e){return!h(e)&&e!==C};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){var i;!1!==(i=t(n,o,e))&&(r[o]=i||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)&&y(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||y(e.append)&&("formdata"===(t=f(e))||"object"===t&&y(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:v,isNumber:b,isBoolean:function(e){return!0===e||!1===e},isObject:g,isPlainObject:w,isUndefined:h,isDate:E,isFile:O,isBlob:S,isRegExp:_,isFunction:y,isStream:function(e){return g(e)&&y(e.pipe)},isURLSearchParams:A,isTypedArray:P,isFileList:R,forEach:T,merge:function e(){for(var t=N(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&&y(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(y(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;var r=e[n];y(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:C,isContextDefined:N,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&&y(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)||y(e))&&y(e.then)&&y(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={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||ie.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, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],(function(e){ie.headers[e]={}}));var ae=ie,se=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"]),ue=Symbol("internals");function ce(e){return e&&String(e).trim().toLowerCase()}function fe(e){return!1===e||null==e?e:q.isArray(e)?e.map(fe):String(e)}function le(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 de=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=ce(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]=fe(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]&&se[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=ce(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=ce(e)){var n=q.findKey(this,e);return!(!n||void 0===this[n]||t&&!le(0,this[n],n,t))}return!1}},{key:"delete",value:function(e,t){var n=this,r=!1;function o(e){if(e=ce(e)){var o=q.findKey(n,e);!o||t&&!le(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&&!le(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]=fe(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]=fe(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[ue]=this[ue]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=ce(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}();de.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),q.reduceDescriptors(de.prototype,(function(e,t){var n=e.value,r=t[0].toUpperCase()+t.slice(1);return{get:function(){return n},set:function(e){this[r]=e}}})),q.freezeMethods(de);var pe=de;function he(e,t){var n=this||ae,r=t||n,o=pe.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 me(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 ye=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 be(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 ge=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 we(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 Ee={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){var r,o,i=e.data,a=pe.from(e.headers).normalize(),s=e.responseType;function u(){e.cancelToken&&e.cancelToken.unsubscribe(r),e.signal&&e.signal.removeEventListener("abort",r)}q.isFormData(i)&&(re.isStandardBrowserEnv||re.isStandardBrowserWebWorkerEnv?a.setContentType(!1):a.getContentType(/^\s*multipart\/form-data/)?q.isString(o=a.getContentType())&&a.setContentType(o.replace(/^\s*(multipart\/form-data);+/,"$1")):a.setContentType("multipart/form-data"));var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",l=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.set("Authorization","Basic "+btoa(f+":"+l))}var d=be(e.baseURL,e.url);function p(){if(c){var r=pe.from("getAllResponseHeaders"in c&&c.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),u()}),(function(e){n(e),u()}),{data:s&&"text"!==s&&"json"!==s?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:r,config:e,request:c}),c=null}}if(c.open(e.method.toUpperCase(),Y(d,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(p)},c.onabort=function(){c&&(n(new M("Request aborted",M.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new M("Network Error",M.ERR_NETWORK,e,c)),c=null},c.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,c)),c=null},re.isStandardBrowserEnv){var h=ge(d)&&e.xsrfCookieName&&ye.read(e.xsrfCookieName);h&&a.set(e.xsrfHeaderName,h)}void 0===i&&a.setContentType(null),"setRequestHeader"in c&&q.forEach(a.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),q.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&"json"!==s&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",we(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",we(e.onUploadProgress)),(e.cancelToken||e.signal)&&(r=function(t){c&&(n(!t||t.type?new ve(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(r),e.signal&&(e.signal.aborted?r():e.signal.addEventListener("abort",r)));var m,v=(m=/^([-+\w]{1,25})(:?\/\/|:)/.exec(d))&&m[1]||"";v&&-1===re.protocols.indexOf(v)?n(new M("Unsupported protocol "+v+":",M.ERR_BAD_REQUEST,e)):c.send(i||null)}))}};q.forEach(Ee,(function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var Oe=function(e){return"- ".concat(e)},Se=function(e){return q.isFunction(e)||null===e||!1===e},Re=function(e){for(var t,n,r=(e=q.isArray(e)?e:[e]).length,i={},a=0;a<r;a++){var s=void 0;if(n=t=e[a],!Se(t)&&void 0===(n=Ee[(s=String(t)).toLowerCase()]))throw new M("Unknown adapter '".concat(s,"'"));if(n)break;i[s||"#"+a]=n}if(!n){var u=Object.entries(i).map((function(e){var t=o(e,2),n=t[0],r=t[1];return"adapter ".concat(n," ")+(!1===r?"is not supported by the environment":"is not available in the build")}));throw new M("There is no suitable adapter to dispatch the request "+(r?u.length>1?"since :\n"+u.map(Oe).join("\n"):" "+Oe(u[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Ae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ve(null,e)}function Te(e){return Ae(e),e.headers=pe.from(e.headers),e.data=he.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Re(e.adapter||ae.adapter)(e).then((function(t){return Ae(e),t.data=he.call(e,e.transformResponse,t),t.headers=pe.from(t.headers),t}),(function(t){return me(t)||(Ae(e),t&&t.response&&(t.response.data=he.call(e,e.transformResponse,t.response),t.response.headers=pe.from(t.response.headers))),Promise.reject(t)}))}var je=function(e){return e instanceof pe?e.toJSON():e};function Ce(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(je(e),je(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.6.0",xe={};["object","boolean","number","function","string","symbol"].forEach((function(t,n){xe[t]=function(r){return e(r)===t||"a"+(n<1?"n ":" ")+t}}));var Pe={};xe.transitional=function(e,t,n){function r(e,t){return"[Axios v1.6.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&&!Pe[o]&&(Pe[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 ke={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:xe},Ue=ke.validators,_e=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=t=Ce(this.defaults,t),r=n.transitional,o=n.paramsSerializer,i=n.headers;void 0!==r&&ke.assertOptions(r,{silentJSONParsing:Ue.transitional(Ue.boolean),forcedJSONParsing:Ue.transitional(Ue.boolean),clarifyTimeoutError:Ue.transitional(Ue.boolean)},!1),null!=o&&(q.isFunction(o)?t.paramsSerializer={serialize:o}:ke.assertOptions(o,{encode:Ue.function,serialize:Ue.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();var a=i&&q.merge(i.common,i[t.method]);i&&q.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete i[e]})),t.headers=pe.concat(a,i);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=[Te.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++],v=s[d++];try{h=m(h)}catch(e){v.call(this,e);break}}try{c=Te.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(be((e=Ce(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}]),e}();q.forEach(["delete","get","head","options"],(function(e){_e.prototype[e]=function(t,n){return this.request(Ce(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(Ce(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}_e.prototype[e]=t(),_e.prototype[e+"Form"]=t(!0)}));var Fe=_e,Be=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 Le={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(Le).forEach((function(e){var t=o(e,2),n=t[0],r=t[1];Le[r]=n}));var De=Le;var Ie=function e(t){var n=new Fe(t),r=a(Fe.prototype.request,n);return q.extend(r,Fe.prototype,n,{allOwnKeys:!0}),q.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Ce(t,n))},r}(ae);return Ie.Axios=Fe,Ie.CanceledError=ve,Ie.CancelToken=Be,Ie.isCancel=me,Ie.VERSION=Ne,Ie.toFormData=G,Ie.AxiosError=M,Ie.Cancel=Ie.CanceledError,Ie.all=function(e){return Promise.all(e)},Ie.spread=function(e){return function(t){return e.apply(null,t)}},Ie.isAxiosError=function(e){return q.isObject(e)&&!0===e.isAxiosError},Ie.mergeConfig=Ce,Ie.AxiosHeaders=pe,Ie.formToJSON=function(e){return oe(q.isHTMLForm(e)?new FormData(e):e)},Ie.getAdapter=Re,Ie.HttpStatusCode=De,Ie.default=Ie,Ie})); | ||
//# sourceMappingURL=axios.min.js.map |
524
index.d.ts
@@ -1,7 +0,114 @@ | ||
export interface AxiosTransformer { | ||
(data: any, headers?: any): any; | ||
// TypeScript Version: 4.7 | ||
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null; | ||
interface RawAxiosHeaders { | ||
[key: string]: AxiosHeaderValue; | ||
} | ||
type MethodsHeaders = Partial<{ | ||
[Key in Method as Lowercase<Key>]: AxiosHeaders; | ||
} & {common: AxiosHeaders}>; | ||
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean); | ||
type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any; | ||
export class AxiosHeaders { | ||
constructor( | ||
headers?: RawAxiosHeaders | AxiosHeaders | string | ||
); | ||
[key: string]: any; | ||
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders; | ||
get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue; | ||
has(header: string, matcher?: 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 RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>; | ||
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders; | ||
export interface AxiosRequestTransformer { | ||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any; | ||
} | ||
export interface AxiosResponseTransformer { | ||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any; | ||
} | ||
export interface AxiosAdapter { | ||
(config: AxiosRequestConfig): AxiosPromise<any>; | ||
(config: InternalAxiosRequestConfig): AxiosPromise; | ||
} | ||
@@ -17,55 +124,213 @@ | ||
port: number; | ||
auth?: { | ||
username: string; | ||
password:string; | ||
}; | ||
auth?: AxiosBasicCredentials; | ||
protocol?: string; | ||
} | ||
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 interface TransitionalOptions{ | ||
silentJSONParsing: boolean; | ||
forcedJSONParsing: boolean; | ||
clarifyTimeoutError: boolean; | ||
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 interface TransitionalOptions { | ||
silentJSONParsing?: boolean; | ||
forcedJSONParsing?: boolean; | ||
clarifyTimeoutError?: boolean; | ||
} | ||
export interface AxiosRequestConfig { | ||
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 type AddressFamily = 4 | 6 | undefined; | ||
export interface LookupAddressEntry { | ||
address: string; | ||
family?: AddressFamily; | ||
} | ||
export type LookupAddress = string | LookupAddressEntry; | ||
export interface AxiosRequestConfig<D = any> { | ||
url?: string; | ||
method?: Method; | ||
method?: Method | string; | ||
baseURL?: string; | ||
transformRequest?: AxiosTransformer | AxiosTransformer[]; | ||
transformResponse?: AxiosTransformer | AxiosTransformer[]; | ||
headers?: any; | ||
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; | ||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; | ||
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders; | ||
params?: any; | ||
paramsSerializer?: (params: any) => string; | ||
data?: any; | ||
timeout?: number; | ||
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer; | ||
data?: D; | ||
timeout?: Milliseconds; | ||
timeoutErrorMessage?: string; | ||
withCredentials?: boolean; | ||
adapter?: AxiosAdapter; | ||
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[]; | ||
auth?: AxiosBasicCredentials; | ||
responseType?: ResponseType; | ||
responseEncoding?: responseEncoding | string; | ||
xsrfCookieName?: string; | ||
xsrfHeaderName?: string; | ||
onUploadProgress?: (progressEvent: any) => void; | ||
onDownloadProgress?: (progressEvent: any) => void; | ||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
maxContentLength?: number; | ||
@@ -75,3 +340,6 @@ validateStatus?: ((status: number) => boolean) | null; | ||
maxRedirects?: number; | ||
maxRate?: number | [MaxUploadRate, MaxDownloadRate]; | ||
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void; | ||
socketPath?: string | null; | ||
transport?: any; | ||
httpAgent?: any; | ||
@@ -82,26 +350,96 @@ httpsAgent?: any; | ||
decompress?: boolean; | ||
transitional?: TransitionalOptions | ||
transitional?: TransitionalOptions; | ||
signal?: GenericAbortSignal; | ||
insecureHTTPParser?: boolean; | ||
env?: { | ||
FormData?: new (...args: any[]) => object; | ||
}; | ||
formSerializer?: FormSerializerOptions; | ||
family?: AddressFamily; | ||
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) | | ||
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>); | ||
} | ||
export interface AxiosResponse<T = any> { | ||
// 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; | ||
} | ||
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> { | ||
headers: HeadersDefaults; | ||
} | ||
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> { | ||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>; | ||
} | ||
export interface AxiosResponse<T = any, D = any> { | ||
data: T; | ||
status: number; | ||
statusText: string; | ||
headers: any; | ||
config: AxiosRequestConfig; | ||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders; | ||
config: InternalAxiosRequestConfig<D>; | ||
request?: any; | ||
} | ||
export interface AxiosError<T = any> extends Error { | ||
config: AxiosRequestConfig; | ||
export class AxiosError<T = unknown, D = any> extends Error { | ||
constructor( | ||
message?: string, | ||
code?: string, | ||
config?: InternalAxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
); | ||
config?: InternalAxiosRequestConfig<D>; | ||
code?: string; | ||
request?: any; | ||
response?: AxiosResponse<T>; | ||
response?: AxiosResponse<T, D>; | ||
isAxiosError: boolean; | ||
status?: number; | ||
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"; | ||
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE"; | ||
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION"; | ||
static readonly ERR_NETWORK = "ERR_NETWORK"; | ||
static readonly ERR_DEPRECATED = "ERR_DEPRECATED"; | ||
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE"; | ||
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"; | ||
static readonly ECONNABORTED = "ECONNABORTED"; | ||
static readonly ETIMEDOUT = "ETIMEDOUT"; | ||
} | ||
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> { | ||
export class CanceledError<T> extends AxiosError<T> { | ||
} | ||
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>; | ||
export interface CancelStatic { | ||
@@ -112,7 +450,7 @@ new (message?: string): Cancel; | ||
export interface Cancel { | ||
message: string; | ||
message: string | undefined; | ||
} | ||
export interface Canceler { | ||
(message?: string): void; | ||
(message?: string, config?: AxiosRequestConfig, request?: any): void; | ||
} | ||
@@ -136,34 +474,86 @@ | ||
export interface AxiosInterceptorOptions { | ||
synchronous?: boolean; | ||
runWhen?: (config: InternalAxiosRequestConfig) => boolean; | ||
} | ||
export interface AxiosInterceptorManager<V> { | ||
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number; | ||
use(onFulfilled?: ((value: V) => V | Promise<V>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions): number; | ||
eject(id: number): void; | ||
clear(): void; | ||
} | ||
export interface AxiosInstance { | ||
(config: AxiosRequestConfig): AxiosPromise; | ||
(url: string, config?: AxiosRequestConfig): AxiosPromise; | ||
defaults: AxiosRequestConfig; | ||
export class Axios { | ||
constructor(config?: AxiosRequestConfig); | ||
defaults: AxiosDefaults; | ||
interceptors: { | ||
request: AxiosInterceptorManager<AxiosRequestConfig>; | ||
request: AxiosInterceptorManager<InternalAxiosRequestConfig>; | ||
response: AxiosInterceptorManager<AxiosResponse>; | ||
}; | ||
getUri(config?: AxiosRequestConfig): string; | ||
request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>; | ||
get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; | ||
delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; | ||
head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; | ||
options<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; | ||
post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>; | ||
put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>; | ||
patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>; | ||
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>; | ||
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
postForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
putForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
patchForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
} | ||
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 | ||
} | ||
}; | ||
} | ||
export interface GenericFormData { | ||
append(name: string, value: any, options?: any): any; | ||
} | ||
export interface GenericHTMLFormElement { | ||
name: string; | ||
method: string; | ||
submit(): void; | ||
} | ||
export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter; | ||
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?: AxiosRequestConfig): AxiosInstance; | ||
create(config?: CreateAxiosDefaults): AxiosInstance; | ||
Cancel: CancelStatic; | ||
CancelToken: CancelTokenStatic; | ||
isCancel(value: any): boolean; | ||
all<T>(values: (T | Promise<T>)[]): Promise<T[]>; | ||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R; | ||
isAxiosError(payload: any): payload is AxiosError; | ||
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; | ||
getAdapter: typeof getAdapter; | ||
CanceledError: typeof CanceledError; | ||
AxiosHeaders: typeof AxiosHeaders; | ||
} | ||
@@ -170,0 +560,0 @@ |
44
index.js
@@ -1,1 +0,43 @@ | ||
module.exports = require('./lib/axios'); | ||
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, | ||
getAdapter, | ||
mergeConfig | ||
} = axios; | ||
export { | ||
axios as default, | ||
Axios, | ||
AxiosError, | ||
CanceledError, | ||
isCancel, | ||
CancelToken, | ||
VERSION, | ||
all, | ||
Cancel, | ||
isAxiosError, | ||
spread, | ||
toFormData, | ||
AxiosHeaders, | ||
HttpStatusCode, | ||
formToJSON, | ||
getAdapter, | ||
mergeConfig | ||
} |
'use strict'; | ||
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 pkg = require('./../../package.json'); | ||
var createError = require('../core/createError'); | ||
var enhanceError = require('../core/enhanceError'); | ||
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 isHttps = /https:?/; | ||
const zlibOptions = { | ||
flush: zlib.constants.Z_SYNC_FLUSH, | ||
finishFlush: zlib.constants.Z_SYNC_FLUSH | ||
}; | ||
const brotliOptions = { | ||
flush: zlib.constants.BROTLI_OPERATION_FLUSH, | ||
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH | ||
} | ||
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} proxy | ||
* @param {AxiosProxyConfig} configProxy configuration from Axios options object | ||
* @param {string} location | ||
* | ||
* @returns {http.ClientRequestArgs} | ||
*/ | ||
function setProxy(options, proxy, location) { | ||
options.hostname = proxy.host; | ||
options.host = proxy.host; | ||
options.port = proxy.port; | ||
options.path = location; | ||
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 || ''); | ||
} | ||
// 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; | ||
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}:`; | ||
} | ||
} | ||
// 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); | ||
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); | ||
}; | ||
} | ||
/*eslint consistent-return:0*/ | ||
module.exports = function httpAdapter(config) { | ||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { | ||
var resolve = function resolve(value) { | ||
resolvePromise(value); | ||
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); | ||
}; | ||
var reject = function reject(value) { | ||
rejectPromise(value); | ||
}; | ||
var data = config.data; | ||
var headers = config.headers; | ||
const _reject = (reason) => { | ||
done(reason, true); | ||
reject(reason); | ||
} | ||
asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject); | ||
}) | ||
}; | ||
const resolveFamily = ({address, family}) => { | ||
if (!utils.isString(address)) { | ||
throw TypeError('address must be a string'); | ||
} | ||
return ({ | ||
address, | ||
family: family || (address.indexOf('.') < 0 ? 6 : 4) | ||
}); | ||
} | ||
const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family}); | ||
/*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) { | ||
const _lookup = callbackify(lookup, (value) => utils.isArray(value) ? value : [value]); | ||
// hotfix to support opt.all option which is required for node 20.x | ||
lookup = (hostname, opt, cb) => { | ||
_lookup(hostname, opt, (err, arg0, arg1) => { | ||
const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)]; | ||
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family); | ||
}); | ||
} | ||
} | ||
// temporary internal emitter until the AxiosRequest class will be implemented | ||
const emitter = new EventEmitter(); | ||
const onFinished = () => { | ||
if (config.cancelToken) { | ||
config.cancelToken.unsubscribe(abort); | ||
} | ||
if (config.signal) { | ||
config.signal.removeEventListener('abort', abort); | ||
} | ||
emitter.removeAllListeners(); | ||
} | ||
onDone((value, isRejected) => { | ||
isDone = true; | ||
if (isRejected) { | ||
rejected = true; | ||
onFinished(); | ||
} | ||
}); | ||
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); | ||
} | ||
} | ||
// 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 | ||
if ('User-Agent' in headers || 'user-agent' in headers) { | ||
// User-Agent is specified; handle case where no UA header is desired | ||
if (!headers['User-Agent'] && !headers['user-agent']) { | ||
delete headers['User-Agent']; | ||
delete headers['user-agent']; | ||
// 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) { | ||
} | ||
} | ||
// Otherwise, use specified value | ||
} else { | ||
// Only set header if it hasn't been set in config | ||
headers['User-Agent'] = 'axios/' + pkg.version; | ||
} | ||
if (data && !utils.isStream(data)) { | ||
} 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)); | ||
} else if (data && !utils.isStream(data)) { | ||
if (Buffer.isBuffer(data)) { | ||
@@ -78,4 +317,5 @@ // Nothing to do... | ||
} else { | ||
return reject(createError( | ||
return reject(new AxiosError( | ||
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
@@ -86,41 +326,91 @@ )); | ||
// Add Content-Length header if data exists | ||
headers['Content-Length'] = data.length; | ||
headers.setContentLength(data.length, false); | ||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) { | ||
return reject(new AxiosError( | ||
'Request body larger than maxBodyLength limit', | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
} | ||
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}); | ||
} | ||
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 | ||
var auth = undefined; | ||
let auth = undefined; | ||
if (config.auth) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password || ''; | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password || ''; | ||
auth = username + ':' + password; | ||
} | ||
// Parse url | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
var parsed = url.parse(fullPath); | ||
var protocol = parsed.protocol || 'http:'; | ||
if (!auth && parsed.auth) { | ||
var urlAuth = parsed.auth.split(':'); | ||
var urlUsername = urlAuth[0] || ''; | ||
var urlPassword = urlAuth[1] || ''; | ||
if (!auth && parsed.username) { | ||
const urlUsername = parsed.username; | ||
const urlPassword = parsed.password; | ||
auth = urlUsername + ':' + urlPassword; | ||
} | ||
if (auth) { | ||
delete headers.Authorization; | ||
auth && headers.delete('authorization'); | ||
let path; | ||
try { | ||
path = buildURL( | ||
parsed.pathname + parsed.search, | ||
config.params, | ||
config.paramsSerializer | ||
).replace(/^\?/, ''); | ||
} catch (err) { | ||
const customErr = new Error(err.message); | ||
customErr.config = config; | ||
customErr.url = config.url; | ||
customErr.exists = true; | ||
return reject(customErr); | ||
} | ||
var isHttpsRequest = isHttps.test(protocol); | ||
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
headers.set( | ||
'Accept-Encoding', | ||
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false | ||
); | ||
var options = { | ||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), | ||
method: config.method.toUpperCase(), | ||
headers: headers, | ||
agent: agent, | ||
const options = { | ||
path, | ||
method: method, | ||
headers: headers.toJSON(), | ||
agents: { http: config.httpAgent, https: config.httpsAgent }, | ||
auth: auth | ||
auth, | ||
protocol, | ||
family, | ||
beforeRedirect: dispatchBeforeRedirect, | ||
beforeRedirects: {} | ||
}; | ||
// cacheable-lookup integration hotfix | ||
!utils.isUndefined(lookup) && (options.lookup = lookup); | ||
if (config.socketPath) { | ||
@@ -131,63 +421,12 @@ options.socketPath = config.socketPath; | ||
options.port = parsed.port; | ||
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path); | ||
} | ||
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); | ||
let transport; | ||
const isHttpsRequest = isHttps.test(options.protocol); | ||
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
if (config.transport) { | ||
transport = config.transport; | ||
} else if (config.maxRedirects === 0) { | ||
transport = isHttpsProxy ? https : http; | ||
transport = isHttpsRequest ? https : http; | ||
} else { | ||
@@ -197,3 +436,6 @@ if (config.maxRedirects) { | ||
} | ||
transport = isHttpsProxy ? httpsFollow : httpFollow; | ||
if (config.beforeRedirect) { | ||
options.beforeRedirects.config = config.beforeRedirect; | ||
} | ||
transport = isHttpsRequest ? httpsFollow : httpFollow; | ||
} | ||
@@ -203,46 +445,100 @@ | ||
options.maxBodyLength = config.maxBodyLength; | ||
} else { | ||
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited | ||
options.maxBodyLength = Infinity; | ||
} | ||
if (config.insecureHTTPParser) { | ||
options.insecureHTTPParser = config.insecureHTTPParser; | ||
} | ||
// Create the request | ||
var req = transport.request(options, function handleResponse(res) { | ||
if (req.aborted) return; | ||
req = transport.request(options, function handleResponse(res) { | ||
if (req.destroyed) return; | ||
// uncompress the response body transparently if required | ||
var stream = res; | ||
const streams = [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 | ||
var lastRequest = res.req || req; | ||
const 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']) { | ||
switch ((res.headers['content-encoding'] || '').toLowerCase()) { | ||
/*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': | ||
// add the unzipper to the body stream processing pipeline | ||
stream = stream.pipe(zlib.createUnzip()); | ||
streams.push(new ZlibHeaderTransformStream()); | ||
// 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']; | ||
} | ||
} | ||
} | ||
var response = { | ||
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0]; | ||
const offListeners = stream.finished(responseStream, () => { | ||
offListeners(); | ||
onFinished(); | ||
}); | ||
const response = { | ||
status: res.statusCode, | ||
statusText: res.statusMessage, | ||
headers: res.headers, | ||
config: config, | ||
headers: new AxiosHeaders(res.headers), | ||
config, | ||
request: lastRequest | ||
}; | ||
if (config.responseType === 'stream') { | ||
response.data = stream; | ||
if (responseType === 'stream') { | ||
response.data = responseStream; | ||
settle(resolve, reject, response); | ||
} else { | ||
var responseBuffer = []; | ||
var totalResponseBytes = 0; | ||
stream.on('data', function handleStreamData(chunk) { | ||
const responseBuffer = []; | ||
let totalResponseBytes = 0; | ||
responseStream.on('data', function handleStreamData(chunk) { | ||
responseBuffer.push(chunk); | ||
@@ -253,44 +549,83 @@ totalResponseBytes += chunk.length; | ||
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) { | ||
stream.destroy(); | ||
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
config, null, lastRequest)); | ||
// stream.destroy() emit aborted event before calling reject() on Node.js v16 | ||
rejected = true; | ||
responseStream.destroy(); | ||
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
AxiosError.ERR_BAD_RESPONSE, config, lastRequest)); | ||
} | ||
}); | ||
stream.on('error', function handleStreamError(err) { | ||
if (req.aborted) return; | ||
reject(enhanceError(err, config, null, lastRequest)); | ||
responseStream.on('aborted', function handlerStreamAborted() { | ||
if (rejected) { | ||
return; | ||
} | ||
const err = new AxiosError( | ||
'maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
AxiosError.ERR_BAD_RESPONSE, | ||
config, | ||
lastRequest | ||
); | ||
responseStream.destroy(err); | ||
reject(err); | ||
}); | ||
stream.on('end', function handleStreamEnd() { | ||
var responseData = Buffer.concat(responseBuffer); | ||
if (config.responseType !== 'arraybuffer') { | ||
responseData = responseData.toString(config.responseEncoding); | ||
if (!config.responseEncoding || config.responseEncoding === 'utf8') { | ||
responseData = utils.stripBOM(responseData); | ||
responseStream.on('error', function handleStreamError(err) { | ||
if (req.destroyed) return; | ||
reject(AxiosError.from(err, null, config, lastRequest)); | ||
}); | ||
responseStream.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') { | ||
responseData = utils.stripBOM(responseData); | ||
} | ||
} | ||
response.data = responseData; | ||
} catch (err) { | ||
return reject(AxiosError.from(err, null, config, response.request, response)); | ||
} | ||
response.data = responseData; | ||
settle(resolve, reject, response); | ||
}); | ||
} | ||
emitter.once('abort', err => { | ||
if (!responseStream.destroyed) { | ||
responseStream.emit('error', err); | ||
responseStream.destroy(); | ||
} | ||
}); | ||
}); | ||
emitter.once('abort', err => { | ||
reject(err); | ||
req.destroy(err); | ||
}); | ||
// Handle errors | ||
req.on('error', function handleRequestError(err) { | ||
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return; | ||
reject(enhanceError(err, config, null, req)); | ||
// @todo remove | ||
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return; | ||
reject(AxiosError.from(err, null, config, req)); | ||
}); | ||
// set tcp keep alive to prevent drop connection by peer | ||
req.on('socket', function handleRequestSocket(socket) { | ||
// default interval of sending ack packet is 1 minute | ||
socket.setKeepAlive(true, 1000 * 60); | ||
}); | ||
// Handle request timeout | ||
if (config.timeout) { | ||
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types. | ||
var timeout = parseInt(config.timeout, 10); | ||
const timeout = parseInt(config.timeout, 10); | ||
if (isNaN(timeout)) { | ||
reject(createError( | ||
if (Number.isNaN(timeout)) { | ||
reject(new AxiosError( | ||
'error trying to parse `config.timeout` to int', | ||
AxiosError.ERR_BAD_OPTION_VALUE, | ||
config, | ||
'ERR_PARSE_TIMEOUT', | ||
req | ||
@@ -305,30 +640,43 @@ )); | ||
// 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 devoring CPU little by little. | ||
// And then these socket which be hang up will devouring 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() { | ||
req.abort(); | ||
reject(createError( | ||
'timeout of ' + timeout + 'ms exceeded', | ||
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; | ||
} | ||
reject(new AxiosError( | ||
timeoutErrorMessage, | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
config, | ||
config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', | ||
req | ||
)); | ||
abort(); | ||
}); | ||
} | ||
if (config.cancelToken) { | ||
// Handle cancellation | ||
config.cancelToken.promise.then(function onCanceled(cancel) { | ||
if (req.aborted) return; | ||
req.abort(); | ||
reject(cancel); | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
let ended = false; | ||
let errored = false; | ||
data.on('end', () => { | ||
ended = true; | ||
}); | ||
} | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
data.on('error', function handleStreamError(err) { | ||
reject(enhanceError(err, config, null, req)); | ||
}).pipe(req); | ||
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); | ||
} else { | ||
@@ -338,2 +686,4 @@ req.end(data); | ||
}); | ||
}; | ||
} | ||
export const __setProxy = setProxy; |
'use strict'; | ||
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 createError = require('../core/createError'); | ||
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'; | ||
module.exports = function xhrAdapter(config) { | ||
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) { | ||
return new Promise(function dispatchXhrRequest(resolve, reject) { | ||
var requestData = config.data; | ||
var requestHeaders = config.headers; | ||
var responseType = config.responseType; | ||
let requestData = config.data; | ||
const requestHeaders = AxiosHeaders.from(config.headers).normalize(); | ||
const responseType = config.responseType; | ||
let onCanceled; | ||
function done() { | ||
if (config.cancelToken) { | ||
config.cancelToken.unsubscribe(onCanceled); | ||
} | ||
if (config.signal) { | ||
config.signal.removeEventListener('abort', onCanceled); | ||
} | ||
} | ||
let contentType; | ||
if (utils.isFormData(requestData)) { | ||
delete requestHeaders['Content-Type']; // Let the browser set it | ||
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) { | ||
requestHeaders.setContentType(false); // Let the browser set it | ||
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){ | ||
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks | ||
} else if(utils.isString(contentType = requestHeaders.getContentType())){ | ||
// fix semicolon duplication issue for ReactNative FormData implementation | ||
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1')) | ||
} | ||
} | ||
var request = new XMLHttpRequest(); | ||
let request = new XMLHttpRequest(); | ||
// HTTP basic authentication | ||
if (config.auth) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password)); | ||
} | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); | ||
@@ -42,6 +98,8 @@ | ||
// Prepare the response | ||
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; | ||
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
const responseHeaders = AxiosHeaders.from( | ||
'getAllResponseHeaders' in request && request.getAllResponseHeaders() | ||
); | ||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
request.responseText : request.response; | ||
var response = { | ||
const response = { | ||
data: responseData, | ||
@@ -51,7 +109,13 @@ status: request.status, | ||
headers: responseHeaders, | ||
config: config, | ||
request: request | ||
config, | ||
request | ||
}; | ||
settle(resolve, reject, response); | ||
settle(function _resolve(value) { | ||
resolve(value); | ||
done(); | ||
}, function _reject(err) { | ||
reject(err); | ||
done(); | ||
}, response); | ||
@@ -91,3 +155,3 @@ // Clean up request | ||
reject(createError('Request aborted', config, 'ECONNABORTED', request)); | ||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request)); | ||
@@ -102,3 +166,3 @@ // Clean up request | ||
// onerror should only fire if it's a network error | ||
reject(createError('Network Error', config, null, request)); | ||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request)); | ||
@@ -111,10 +175,11 @@ // Clean up request | ||
request.ontimeout = function handleTimeout() { | ||
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
timeoutErrorMessage = config.timeoutErrorMessage; | ||
} | ||
reject(createError( | ||
reject(new AxiosError( | ||
timeoutErrorMessage, | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
config, | ||
config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', | ||
request)); | ||
@@ -129,23 +194,19 @@ | ||
// Specifically not if we're in a web worker, or react-native. | ||
if (utils.isStandardBrowserEnv()) { | ||
if (platform.isStandardBrowserEnv) { | ||
// Add xsrf header | ||
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? | ||
cookies.read(config.xsrfCookieName) : | ||
undefined; | ||
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily | ||
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName); | ||
if (xsrfValue) { | ||
requestHeaders[config.xsrfHeaderName] = xsrfValue; | ||
requestHeaders.set(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, 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); | ||
} | ||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { | ||
request.setRequestHeader(key, val); | ||
}); | ||
@@ -166,3 +227,3 @@ } | ||
if (typeof config.onDownloadProgress === 'function') { | ||
request.addEventListener('progress', config.onDownloadProgress); | ||
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true)); | ||
} | ||
@@ -172,26 +233,34 @@ | ||
if (typeof config.onUploadProgress === 'function' && request.upload) { | ||
request.upload.addEventListener('progress', config.onUploadProgress); | ||
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress)); | ||
} | ||
if (config.cancelToken) { | ||
if (config.cancelToken || config.signal) { | ||
// Handle cancellation | ||
config.cancelToken.promise.then(function onCanceled(cancel) { | ||
// eslint-disable-next-line func-names | ||
onCanceled = cancel => { | ||
if (!request) { | ||
return; | ||
} | ||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel); | ||
request.abort(); | ||
reject(cancel); | ||
// Clean up request | ||
request = null; | ||
}); | ||
}; | ||
config.cancelToken && config.cancelToken.subscribe(onCanceled); | ||
if (config.signal) { | ||
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); | ||
} | ||
} | ||
if (!requestData) { | ||
requestData = null; | ||
const protocol = parseProtocol(fullPath); | ||
if (protocol && platform.protocols.indexOf(protocol) === -1) { | ||
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config)); | ||
return; | ||
} | ||
// Send the request | ||
request.send(requestData); | ||
request.send(requestData || null); | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./utils'); | ||
var bind = require('./helpers/bind'); | ||
var Axios = require('./core/Axios'); | ||
var mergeConfig = require('./core/mergeConfig'); | ||
var defaults = require('./defaults'); | ||
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 adapters from './adapters/adapters.js'; | ||
import HttpStatusCode from './helpers/HttpStatusCode.js'; | ||
@@ -13,14 +25,20 @@ /** | ||
* @param {Object} defaultConfig The default config for the instance | ||
* @return {Axios} A new instance of Axios | ||
* | ||
* @returns {Axios} A new instance of Axios | ||
*/ | ||
function createInstance(defaultConfig) { | ||
var context = new Axios(defaultConfig); | ||
var instance = bind(Axios.prototype.request, context); | ||
const context = new Axios(defaultConfig); | ||
const instance = bind(Axios.prototype.request, context); | ||
// Copy axios.prototype to instance | ||
utils.extend(instance, Axios.prototype, context); | ||
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true}); | ||
// Copy context to instance | ||
utils.extend(instance, context); | ||
utils.extend(instance, context, null, {allOwnKeys: true}); | ||
// Factory for creating new instances | ||
instance.create = function create(instanceConfig) { | ||
return createInstance(mergeConfig(defaultConfig, instanceConfig)); | ||
}; | ||
return instance; | ||
@@ -30,3 +48,3 @@ } | ||
// Create the default instance to be exported | ||
var axios = createInstance(defaults); | ||
const axios = createInstance(defaults); | ||
@@ -36,12 +54,15 @@ // Expose Axios class to allow class inheritance | ||
// Factory for creating new instances | ||
axios.create = function create(instanceConfig) { | ||
return createInstance(mergeConfig(axios.defaults, instanceConfig)); | ||
}; | ||
// Expose Cancel & CancelToken | ||
axios.Cancel = require('./cancel/Cancel'); | ||
axios.CancelToken = require('./cancel/CancelToken'); | ||
axios.isCancel = require('./cancel/isCancel'); | ||
axios.CanceledError = CanceledError; | ||
axios.CancelToken = CancelToken; | ||
axios.isCancel = isCancel; | ||
axios.VERSION = VERSION; | ||
axios.toFormData = toFormData; | ||
// Expose AxiosError class | ||
axios.AxiosError = AxiosError; | ||
// alias for CanceledError for backward compatibility | ||
axios.Cancel = axios.CanceledError; | ||
// Expose all/spread | ||
@@ -51,10 +72,22 @@ axios.all = function all(promises) { | ||
}; | ||
axios.spread = require('./helpers/spread'); | ||
axios.spread = spread; | ||
// Expose isAxiosError | ||
axios.isAxiosError = require('./helpers/isAxiosError'); | ||
axios.isAxiosError = isAxiosError; | ||
module.exports = axios; | ||
// Expose mergeConfig | ||
axios.mergeConfig = mergeConfig; | ||
// Allow use of default import syntax in TypeScript | ||
module.exports.default = axios; | ||
axios.AxiosHeaders = AxiosHeaders; | ||
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing); | ||
axios.getAdapter = adapters.getAdapter; | ||
axios.HttpStatusCode = HttpStatusCode; | ||
axios.default = axios; | ||
// this module should only have a default export | ||
export default axios |
'use strict'; | ||
var Cancel = require('./Cancel'); | ||
import CanceledError from './CanceledError.js'; | ||
@@ -8,51 +8,115 @@ /** | ||
* | ||
* @class | ||
* @param {Function} executor The executor function. | ||
* | ||
* @returns {CancelToken} | ||
*/ | ||
function CancelToken(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
class CancelToken { | ||
constructor(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
let resolvePromise; | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
const token = this; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(cancel => { | ||
if (!token._listeners) return; | ||
let i = token._listeners.length; | ||
while (i-- > 0) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
// 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); | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
}; | ||
return promise; | ||
}; | ||
executor(function cancel(message, config, request) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
} | ||
token.reason = new CanceledError(message, config, request); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
var resolvePromise; | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
} | ||
var token = this; | ||
executor(function cancel(message) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
token.reason = new Cancel(message); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
} | ||
} | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
*/ | ||
CancelToken.prototype.throwIfRequested = function throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
/** | ||
* 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); | ||
} | ||
} | ||
}; | ||
/** | ||
* 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 | ||
}; | ||
}; | ||
/** | ||
* 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 | ||
}; | ||
} | ||
} | ||
module.exports = CancelToken; | ||
export default CancelToken; |
'use strict'; | ||
module.exports = function isCancel(value) { | ||
export default function isCancel(value) { | ||
return !!(value && value.__CANCEL__); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var buildURL = require('../helpers/buildURL'); | ||
var InterceptorManager = require('./InterceptorManager'); | ||
var dispatchRequest = require('./dispatchRequest'); | ||
var mergeConfig = require('./mergeConfig'); | ||
var validator = require('../helpers/validator'); | ||
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 validators = validator.validators; | ||
const validators = validator.validators; | ||
/** | ||
@@ -15,112 +18,152 @@ * 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 | ||
* | ||
* @param {Object} config The config specific for this request (merged with this.defaults) | ||
* @return {Axios} A new instance of Axios | ||
*/ | ||
Axios.prototype.request = function request(config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof config === 'string') { | ||
config = arguments[1] || {}; | ||
config.url = arguments[0]; | ||
} else { | ||
config = config || {}; | ||
class Axios { | ||
constructor(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
/** | ||
* 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 || {}; | ||
} | ||
// 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'; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
var transitional = config.transitional; | ||
const {transitional, paramsSerializer, headers} = config; | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'), | ||
forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'), | ||
clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0') | ||
}, false); | ||
} | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
// 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; | ||
if (paramsSerializer != null) { | ||
if (utils.isFunction(paramsSerializer)) { | ||
config.paramsSerializer = { | ||
serialize: paramsSerializer | ||
} | ||
} else { | ||
validator.assertOptions(paramsSerializer, { | ||
encode: validators.function, | ||
serialize: validators.function | ||
}, true); | ||
} | ||
} | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
// Set config.method | ||
config.method = (config.method || this.defaults.method || 'get').toLowerCase(); | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
// Flatten headers | ||
let contextHeaders = headers && utils.merge( | ||
headers.common, | ||
headers[config.method] | ||
); | ||
var responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
headers && 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; | ||
promise = Promise.resolve(config); | ||
while (chain.length) { | ||
promise = promise.then(chain.shift(), chain.shift()); | ||
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; | ||
} | ||
return promise; | ||
} | ||
len = requestInterceptorChain.length; | ||
let newConfig = config; | ||
var newConfig = config; | ||
while (requestInterceptorChain.length) { | ||
var onFulfilled = requestInterceptorChain.shift(); | ||
var onRejected = requestInterceptorChain.shift(); | ||
i = 0; | ||
while (i < len) { | ||
const onFulfilled = requestInterceptorChain[i++]; | ||
const onRejected = requestInterceptorChain[i++]; | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
} catch (error) { | ||
onRejected.call(this, error); | ||
break; | ||
} | ||
} | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
promise = dispatchRequest.call(this, newConfig); | ||
} catch (error) { | ||
onRejected(error); | ||
break; | ||
return Promise.reject(error); | ||
} | ||
} | ||
try { | ||
promise = dispatchRequest(newConfig); | ||
} catch (error) { | ||
return Promise.reject(error); | ||
i = 0; | ||
len = responseInterceptorChain.length; | ||
while (i < len) { | ||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]); | ||
} | ||
return promise; | ||
} | ||
while (responseInterceptorChain.length) { | ||
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); | ||
getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
} | ||
} | ||
return promise; | ||
}; | ||
Axios.prototype.getUri = function getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
}; | ||
// Provide aliases for supported request methods | ||
@@ -131,4 +174,4 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url, | ||
method, | ||
url, | ||
data: (config || {}).data | ||
@@ -141,11 +184,21 @@ })); | ||
/*eslint func-names:0*/ | ||
Axios.prototype[method] = function(url, data, config) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url, | ||
data: data | ||
})); | ||
}; | ||
function generateHTTPMethod(isForm) { | ||
return function httpMethod(url, data, config) { | ||
return this.request(mergeConfig(config || {}, { | ||
method, | ||
headers: isForm ? { | ||
'Content-Type': 'multipart/form-data' | ||
} : {}, | ||
url, | ||
data | ||
})); | ||
}; | ||
} | ||
Axios.prototype[method] = generateHTTPMethod(); | ||
Axios.prototype[method + 'Form'] = generateHTTPMethod(true); | ||
}); | ||
module.exports = Axios; | ||
export default Axios; |
'use strict'; | ||
var isAbsoluteURL = require('../helpers/isAbsoluteURL'); | ||
var combineURLs = require('../helpers/combineURLs'); | ||
import isAbsoluteURL from '../helpers/isAbsoluteURL.js'; | ||
import combineURLs from '../helpers/combineURLs.js'; | ||
@@ -13,5 +13,6 @@ /** | ||
* @param {string} requestedURL Absolute or relative URL to combine | ||
* | ||
* @returns {string} The combined full path | ||
*/ | ||
module.exports = function buildFullPath(baseURL, requestedURL) { | ||
export default function buildFullPath(baseURL, requestedURL) { | ||
if (baseURL && !isAbsoluteURL(requestedURL)) { | ||
@@ -21,2 +22,2 @@ return combineURLs(baseURL, requestedURL); | ||
return requestedURL; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var transformData = require('./transformData'); | ||
var isCancel = require('../cancel/isCancel'); | ||
var defaults = require('../defaults'); | ||
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"; | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
* | ||
* @param {Object} config The config that is to be used for the request | ||
* | ||
* @returns {void} | ||
*/ | ||
@@ -15,2 +21,6 @@ function throwIfCancellationRequested(config) { | ||
} | ||
if (config.signal && config.signal.aborted) { | ||
throw new CanceledError(null, config); | ||
} | ||
} | ||
@@ -22,9 +32,9 @@ | ||
* @param {object} config The config that is to be used for the request | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
module.exports = function dispatchRequest(config) { | ||
export default function dispatchRequest(config) { | ||
throwIfCancellationRequested(config); | ||
// Ensure headers exist | ||
config.headers = config.headers || {}; | ||
config.headers = AxiosHeaders.from(config.headers); | ||
@@ -34,23 +44,11 @@ // Transform request data | ||
config, | ||
config.data, | ||
config.headers, | ||
config.transformRequest | ||
); | ||
// Flatten headers | ||
config.headers = utils.merge( | ||
config.headers.common || {}, | ||
config.headers[config.method] || {}, | ||
config.headers | ||
); | ||
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) { | ||
config.headers.setContentType('application/x-www-form-urlencoded', false); | ||
} | ||
utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
} | ||
); | ||
const adapter = adapters.getAdapter(config.adapter || defaults.adapter); | ||
var adapter = config.adapter || defaults.adapter; | ||
return adapter(config).then(function onAdapterResolution(response) { | ||
@@ -62,7 +60,8 @@ throwIfCancellationRequested(config); | ||
config, | ||
response.data, | ||
response.headers, | ||
config.transformResponse | ||
config.transformResponse, | ||
response | ||
); | ||
response.headers = AxiosHeaders.from(response.headers); | ||
return response; | ||
@@ -77,6 +76,6 @@ }, function onAdapterRejection(reason) { | ||
config, | ||
reason.response.data, | ||
reason.response.headers, | ||
config.transformResponse | ||
config.transformResponse, | ||
reason.response | ||
); | ||
reason.response.headers = AxiosHeaders.from(reason.response.headers); | ||
} | ||
@@ -87,2 +86,2 @@ } | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
function InterceptorManager() { | ||
this.handlers = []; | ||
} | ||
class InterceptorManager { | ||
constructor() { | ||
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 | ||
*/ | ||
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; | ||
}; | ||
/** | ||
* 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; | ||
} | ||
/** | ||
* 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; | ||
/** | ||
* 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; | ||
} | ||
} | ||
}; | ||
/** | ||
* 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); | ||
/** | ||
* Clear all interceptors from the stack | ||
* | ||
* @returns {void} | ||
*/ | ||
clear() { | ||
if (this.handlers) { | ||
this.handlers = []; | ||
} | ||
}); | ||
}; | ||
} | ||
module.exports = InterceptorManager; | ||
/** | ||
* 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; |
'use strict'; | ||
var utils = require('../utils'); | ||
import utils from '../utils.js'; | ||
import AxiosHeaders from "./AxiosHeaders.js"; | ||
const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing; | ||
/** | ||
@@ -11,23 +14,13 @@ * Config-specific merge-function which creates a new config-object | ||
* @param {Object} config2 | ||
* | ||
* @returns {Object} New object resulting from merging config2 to config1 | ||
*/ | ||
module.exports = function mergeConfig(config1, config2) { | ||
export default function mergeConfig(config1, config2) { | ||
// eslint-disable-next-line no-param-reassign | ||
config2 = config2 || {}; | ||
var config = {}; | ||
const config = {}; | ||
var valueFromConfig2Keys = ['url', 'method', 'data']; | ||
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; | ||
var defaultToConfig2Keys = [ | ||
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', | ||
'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', | ||
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', | ||
'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', | ||
'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' | ||
]; | ||
var directMergeKeys = ['validateStatus']; | ||
function getMergedValue(target, source) { | ||
function getMergedValue(target, source, caseless) { | ||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) { | ||
return utils.merge(target, source); | ||
return utils.merge.call({caseless}, target, source); | ||
} else if (utils.isPlainObject(source)) { | ||
@@ -41,49 +34,74 @@ return utils.merge({}, source); | ||
function mergeDeepProperties(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
config[prop] = getMergedValue(config1[prop], config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
config[prop] = getMergedValue(undefined, config1[prop]); | ||
// 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); | ||
} | ||
} | ||
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
config[prop] = getMergedValue(undefined, config2[prop]); | ||
// eslint-disable-next-line consistent-return | ||
function valueFromConfig2(a, b) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(undefined, b); | ||
} | ||
}); | ||
} | ||
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); | ||
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
config[prop] = getMergedValue(undefined, config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
config[prop] = getMergedValue(undefined, config1[prop]); | ||
// 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); | ||
} | ||
}); | ||
} | ||
utils.forEach(directMergeKeys, function merge(prop) { | ||
// eslint-disable-next-line consistent-return | ||
function mergeDirectKeys(a, b, prop) { | ||
if (prop in config2) { | ||
config[prop] = getMergedValue(config1[prop], config2[prop]); | ||
return getMergedValue(a, b); | ||
} else if (prop in config1) { | ||
config[prop] = getMergedValue(undefined, config1[prop]); | ||
return getMergedValue(undefined, a); | ||
} | ||
}); | ||
} | ||
var axiosKeys = valueFromConfig2Keys | ||
.concat(mergeDeepPropertiesKeys) | ||
.concat(defaultToConfig2Keys) | ||
.concat(directMergeKeys); | ||
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 otherKeys = Object | ||
.keys(config1) | ||
.concat(Object.keys(config2)) | ||
.filter(function filterAxiosKeys(key) { | ||
return axiosKeys.indexOf(key) === -1; | ||
}); | ||
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.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); | ||
}); | ||
utils.forEach(otherKeys, mergeDeepProperties); | ||
return config; | ||
}; | ||
} |
'use strict'; | ||
var createError = require('./createError'); | ||
import AxiosError from './AxiosError.js'; | ||
@@ -11,12 +11,14 @@ /** | ||
* @param {object} response The response. | ||
* | ||
* @returns {object} The response. | ||
*/ | ||
module.exports = function settle(resolve, reject, response) { | ||
var validateStatus = response.config.validateStatus; | ||
export default function settle(resolve, reject, response) { | ||
const validateStatus = response.config.validateStatus; | ||
if (!response.status || !validateStatus || validateStatus(response.status)) { | ||
resolve(response); | ||
} else { | ||
reject(createError( | ||
reject(new AxiosError( | ||
'Request failed with status code ' + response.status, | ||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], | ||
response.config, | ||
null, | ||
response.request, | ||
@@ -26,2 +28,2 @@ response | ||
} | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var defaults = require('./../defaults'); | ||
import utils from './../utils.js'; | ||
import defaults from '../defaults/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
@@ -9,15 +10,20 @@ /** | ||
* | ||
* @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 | ||
*/ | ||
module.exports = function transformData(data, headers, fns) { | ||
var context = this || defaults; | ||
/*eslint no-param-reassign:0*/ | ||
export default function transformData(fns, response) { | ||
const config = this || defaults; | ||
const context = response || config; | ||
const headers = AxiosHeaders.from(context.headers); | ||
let data = context.data; | ||
utils.forEach(fns, function transform(fn) { | ||
data = fn.call(context, data, headers); | ||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); | ||
}); | ||
headers.normalize(); | ||
return data; | ||
}; | ||
} |
'use strict'; | ||
module.exports = function bind(fn, thisArg) { | ||
export default function bind(fn, thisArg) { | ||
return function wrap() { | ||
var args = new Array(arguments.length); | ||
for (var i = 0; i < args.length; i++) { | ||
args[i] = arguments[i]; | ||
} | ||
return fn.apply(thisArg, args); | ||
return fn.apply(thisArg, arguments); | ||
}; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from '../utils.js'; | ||
import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js'; | ||
/** | ||
* 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) { | ||
@@ -20,5 +29,7 @@ return encodeURIComponent(val). | ||
* @param {object} [params] The params to be appended | ||
* @param {?object} options | ||
* | ||
* @returns {string} The formatted url | ||
*/ | ||
module.exports = function buildURL(url, params, paramsSerializer) { | ||
export default function buildURL(url, params, options) { | ||
/*eslint no-param-reassign:0*/ | ||
@@ -28,41 +39,23 @@ if (!params) { | ||
} | ||
const _encode = options && options.encode || encode; | ||
var serializedParams; | ||
if (paramsSerializer) { | ||
serializedParams = paramsSerializer(params); | ||
} else if (utils.isURLSearchParams(params)) { | ||
serializedParams = params.toString(); | ||
} else { | ||
var parts = []; | ||
const serializeFn = options && options.serialize; | ||
utils.forEach(params, function serialize(val, key) { | ||
if (val === null || typeof val === 'undefined') { | ||
return; | ||
} | ||
let serializedParams; | ||
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 (serializeFn) { | ||
serializedParams = serializeFn(params, options); | ||
} else { | ||
serializedParams = utils.isURLSearchParams(params) ? | ||
params.toString() : | ||
new AxiosURLSearchParams(params, options).toString(_encode); | ||
} | ||
if (serializedParams) { | ||
var hashmarkIndex = url.indexOf('#'); | ||
const hashmarkIndex = url.indexOf("#"); | ||
if (hashmarkIndex !== -1) { | ||
url = url.slice(0, hashmarkIndex); | ||
} | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; | ||
@@ -72,2 +65,2 @@ } | ||
return url; | ||
}; | ||
} |
@@ -8,8 +8,9 @@ 'use strict'; | ||
* @param {string} relativeURL The relative URL | ||
* | ||
* @returns {string} The combined URL | ||
*/ | ||
module.exports = function combineURLs(baseURL, relativeURL) { | ||
export default function combineURLs(baseURL, relativeURL) { | ||
return relativeURL | ||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') | ||
: baseURL; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
export default platform.isStandardBrowserEnv ? | ||
// 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)); | ||
// 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)); | ||
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) { | ||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
read: function read(name) { | ||
const 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,4 +12,6 @@ 'use strict'; | ||
* @param {string} [docs] The documentation URL to get further details | ||
* | ||
* @returns {void} | ||
*/ | ||
module.exports = function deprecatedMethod(method, instead, docs) { | ||
export default function deprecatedMethod(method, instead, docs) { | ||
try { | ||
@@ -25,2 +27,2 @@ console.warn( | ||
} catch (e) { /* Ignore */ } | ||
}; | ||
} |
@@ -7,9 +7,10 @@ 'use strict'; | ||
* @param {string} url The URL to test | ||
* | ||
* @returns {boolean} True if the specified URL is absolute, otherwise false | ||
*/ | ||
module.exports = function isAbsoluteURL(url) { | ||
export default function isAbsoluteURL(url) { | ||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). | ||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed | ||
// by any combination of letters, digits, plus, period, or hyphen. | ||
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); | ||
}; | ||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); | ||
} |
'use strict'; | ||
import utils from './../utils.js'; | ||
/** | ||
@@ -7,6 +9,7 @@ * Determines whether the payload is an error thrown by Axios | ||
* @param {*} payload The value to test | ||
* | ||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false | ||
*/ | ||
module.exports = function isAxiosError(payload) { | ||
return (typeof payload === 'object') && (payload.isAxiosError === true); | ||
}; | ||
export default function isAxiosError(payload) { | ||
return utils.isObject(payload) && (payload.isAxiosError === true); | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
export default platform.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() { | ||
var msie = /(msie|trident)/i.test(navigator.userAgent); | ||
var urlParsingNode = document.createElement('a'); | ||
var 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() { | ||
const msie = /(msie|trident)/i.test(navigator.userAgent); | ||
const urlParsingNode = document.createElement('a'); | ||
let originURL; | ||
/** | ||
/** | ||
* Parse a URL to discover it's components | ||
@@ -21,31 +21,31 @@ * | ||
*/ | ||
function resolveURL(url) { | ||
var href = url; | ||
function resolveURL(url) { | ||
let 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); | ||
// 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 | ||
}; | ||
href = urlParsingNode.href; | ||
} | ||
originURL = resolveURL(window.location.href); | ||
urlParsingNode.setAttribute('href', 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,15 +56,14 @@ * | ||
*/ | ||
return function isURLSameOrigin(requestURL) { | ||
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
}; | ||
})() : | ||
return function isURLSameOrigin(requestURL) { | ||
const 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; | ||
}; | ||
})(); |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
// Headers whose duplicates are ignored by node | ||
// RawAxiosHeaders whose duplicates are ignored by node | ||
// c.f. https://nodejs.org/api/http.html#http_message_headers | ||
var ignoreDuplicateOf = [ | ||
const ignoreDuplicateOf = utils.toObjectSet([ | ||
'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,27 +25,29 @@ /** | ||
* | ||
* @param {String} headers Headers needing to be parsed | ||
* @param {String} rawHeaders Headers needing to be parsed | ||
* | ||
* @returns {Object} Headers parsed into an object | ||
*/ | ||
module.exports = function parseHeaders(headers) { | ||
var parsed = {}; | ||
var key; | ||
var val; | ||
var i; | ||
export default rawHeaders => { | ||
const parsed = {}; | ||
let key; | ||
let val; | ||
let i; | ||
if (!headers) { return parsed; } | ||
utils.forEach(headers.split('\n'), function parser(line) { | ||
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) { | ||
i = line.indexOf(':'); | ||
key = utils.trim(line.substr(0, i)).toLowerCase(); | ||
val = utils.trim(line.substr(i + 1)); | ||
key = line.substring(0, i).trim().toLowerCase(); | ||
val = line.substring(i + 1).trim(); | ||
if (key) { | ||
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); | ||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
if (parsed[key]) { | ||
parsed[key].push(val); | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
parsed[key] = [val]; | ||
} | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
} | ||
@@ -52,0 +54,0 @@ }); |
@@ -21,8 +21,9 @@ 'use strict'; | ||
* @param {Function} callback | ||
* | ||
* @returns {Function} | ||
*/ | ||
module.exports = function spread(callback) { | ||
export default function spread(callback) { | ||
return function wrap(arr) { | ||
return callback.apply(null, arr); | ||
}; | ||
}; | ||
} |
'use strict'; | ||
var pkg = require('./../../package.json'); | ||
import {VERSION} from '../env/data.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
var validators = {}; | ||
const validators = {}; | ||
// eslint-disable-next-line func-names | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => { | ||
validators[type] = function validator(thing) { | ||
@@ -14,45 +15,28 @@ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; | ||
var deprecatedWarnings = {}; | ||
var currentVerArr = pkg.version.split('.'); | ||
const deprecatedWarnings = {}; | ||
/** | ||
* Compare package versions | ||
* @param {string} version | ||
* @param {string?} thanVersion | ||
* @returns {boolean} | ||
*/ | ||
function isOlderVersion(version, thanVersion) { | ||
var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr; | ||
var destVer = version.split('.'); | ||
for (var i = 0; i < 3; i++) { | ||
if (pkgVersionArr[i] > destVer[i]) { | ||
return true; | ||
} else if (pkgVersionArr[i] < destVer[i]) { | ||
return false; | ||
} | ||
} | ||
return false; | ||
} | ||
/** | ||
* Transitional option validator | ||
* @param {function|boolean?} validator | ||
* @param {string?} version | ||
* @param {string} message | ||
* | ||
* @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} | ||
*/ | ||
validators.transitional = function transitional(validator, version, message) { | ||
var isDeprecated = version && isOlderVersion(version); | ||
function formatMessage(opt, desc) { | ||
return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); | ||
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); | ||
} | ||
// eslint-disable-next-line func-names | ||
return function(value, opt, opts) { | ||
return (value, opt, opts) => { | ||
if (validator === false) { | ||
throw new Error(formatMessage(opt, ' has been removed in ' + version)); | ||
throw new AxiosError( | ||
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), | ||
AxiosError.ERR_DEPRECATED | ||
); | ||
} | ||
if (isDeprecated && !deprecatedWarnings[opt]) { | ||
if (version && !deprecatedWarnings[opt]) { | ||
deprecatedWarnings[opt] = true; | ||
@@ -74,5 +58,8 @@ // eslint-disable-next-line no-console | ||
* Assert object's properties type | ||
* | ||
* @param {object} options | ||
* @param {object} schema | ||
* @param {boolean?} allowUnknown | ||
* | ||
* @returns {object} | ||
*/ | ||
@@ -82,14 +69,14 @@ | ||
if (typeof options !== 'object') { | ||
throw new TypeError('options must be an object'); | ||
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE); | ||
} | ||
var keys = Object.keys(options); | ||
var i = keys.length; | ||
const keys = Object.keys(options); | ||
let i = keys.length; | ||
while (i-- > 0) { | ||
var opt = keys[i]; | ||
var validator = schema[opt]; | ||
const opt = keys[i]; | ||
const validator = schema[opt]; | ||
if (validator) { | ||
var value = options[opt]; | ||
var result = value === undefined || validator(value, opt, options); | ||
const value = options[opt]; | ||
const result = value === undefined || validator(value, opt, options); | ||
if (result !== true) { | ||
throw new TypeError('option ' + opt + ' must be ' + result); | ||
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); | ||
} | ||
@@ -99,3 +86,3 @@ continue; | ||
if (allowUnknown !== true) { | ||
throw Error('Unknown option ' + opt); | ||
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION); | ||
} | ||
@@ -105,6 +92,5 @@ } | ||
module.exports = { | ||
isOlderVersion: isOlderVersion, | ||
assertOptions: assertOptions, | ||
validators: validators | ||
export default { | ||
assertOptions, | ||
validators | ||
}; |
664
lib/utils.js
'use strict'; | ||
var bind = require('./helpers/bind'); | ||
import bind from './helpers/bind.js'; | ||
// utils is a library of generic helper functions non-specific to axios | ||
var toString = Object.prototype.toString; | ||
const {toString} = Object.prototype; | ||
const {getPrototypeOf} = Object; | ||
const kindOf = (cache => thing => { | ||
const str = toString.call(thing); | ||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); | ||
})(Object.create(null)); | ||
const kindOfTest = (type) => { | ||
type = type.toLowerCase(); | ||
return (thing) => kindOf(thing) === type | ||
} | ||
const typeOfTest = type => thing => typeof thing === type; | ||
/** | ||
@@ -13,7 +26,6 @@ * Determine if a value is an Array | ||
* @param {Object} val The value to test | ||
* | ||
* @returns {boolean} True if value is an Array, otherwise false | ||
*/ | ||
function isArray(val) { | ||
return toString.call(val) === '[object Array]'; | ||
} | ||
const {isArray} = Array; | ||
@@ -23,8 +35,7 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if the value is undefined, otherwise false | ||
*/ | ||
function isUndefined(val) { | ||
return typeof val === 'undefined'; | ||
} | ||
const isUndefined = typeOfTest('undefined'); | ||
@@ -34,3 +45,4 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Buffer, otherwise false | ||
@@ -40,3 +52,3 @@ */ | ||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) | ||
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); | ||
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val); | ||
} | ||
@@ -47,18 +59,8 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBuffer(val) { | ||
return toString.call(val) === '[object ArrayBuffer]'; | ||
} | ||
const isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
/** | ||
* Determine if a value is a FormData | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
function isFormData(val) { | ||
return (typeof FormData !== 'undefined') && (val instanceof FormData); | ||
} | ||
@@ -68,11 +70,12 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBufferView(val) { | ||
var result; | ||
let result; | ||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { | ||
result = ArrayBuffer.isView(val); | ||
} else { | ||
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); | ||
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer)); | ||
} | ||
@@ -85,18 +88,24 @@ return result; | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a String, otherwise false | ||
*/ | ||
function isString(val) { | ||
return typeof val === 'string'; | ||
} | ||
const isString = typeOfTest('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 {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Number, otherwise false | ||
*/ | ||
function isNumber(val) { | ||
return typeof val === 'number'; | ||
} | ||
const isNumber = typeOfTest('number'); | ||
@@ -106,22 +115,30 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} thing The value to test | ||
* | ||
* @returns {boolean} True if value is an Object, otherwise false | ||
*/ | ||
function isObject(val) { | ||
return val !== null && typeof val === 'object'; | ||
} | ||
const isObject = (thing) => thing !== null && typeof thing === '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 {Object} val The value to test | ||
* @return {boolean} True if value is a plain Object, otherwise false | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a plain Object, otherwise false | ||
*/ | ||
function isPlainObject(val) { | ||
if (toString.call(val) !== '[object Object]') { | ||
const isPlainObject = (val) => { | ||
if (kindOf(val) !== 'object') { | ||
return false; | ||
} | ||
var prototype = Object.getPrototypeOf(val); | ||
return prototype === null || prototype === Object.prototype; | ||
const prototype = getPrototypeOf(val); | ||
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val); | ||
} | ||
@@ -132,8 +149,7 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Date, otherwise false | ||
*/ | ||
function isDate(val) { | ||
return toString.call(val) === '[object Date]'; | ||
} | ||
const isDate = kindOfTest('Date'); | ||
@@ -143,8 +159,7 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
function isFile(val) { | ||
return toString.call(val) === '[object File]'; | ||
} | ||
const isFile = kindOfTest('File'); | ||
@@ -154,18 +169,16 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Blob, otherwise false | ||
*/ | ||
function isBlob(val) { | ||
return toString.call(val) === '[object Blob]'; | ||
} | ||
const isBlob = kindOfTest('Blob'); | ||
/** | ||
* Determine if a value is a Function | ||
* Determine if a value is a FileList | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
function isFunction(val) { | ||
return toString.call(val) === '[object Function]'; | ||
} | ||
const isFileList = kindOfTest('FileList'); | ||
@@ -175,7 +188,26 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Stream, otherwise false | ||
*/ | ||
function isStream(val) { | ||
return isObject(val) && isFunction(val.pipe); | ||
const isStream = (val) => isObject(val) && isFunction(val.pipe); | ||
/** | ||
* Determine if a value is a FormData | ||
* | ||
* @param {*} thing The value to test | ||
* | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
const isFormData = (thing) => { | ||
let kind; | ||
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]') | ||
) | ||
) | ||
) | ||
} | ||
@@ -186,8 +218,7 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false | ||
*/ | ||
function isURLSearchParams(val) { | ||
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; | ||
} | ||
const isURLSearchParams = kindOfTest('URLSearchParams'); | ||
@@ -198,36 +229,9 @@ /** | ||
* @param {String} str The String to trim | ||
* | ||
* @returns {String} The String freed of excess whitespace | ||
*/ | ||
function trim(str) { | ||
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); | ||
} | ||
const trim = (str) => str.trim ? | ||
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/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. | ||
@@ -243,4 +247,7 @@ * | ||
* @param {Function} fn The callback to invoke for each item | ||
* | ||
* @param {Boolean} [allOwnKeys = false] | ||
* @returns {any} | ||
*/ | ||
function forEach(obj, fn) { | ||
function forEach(obj, fn, {allOwnKeys = false} = {}) { | ||
// Don't bother if no value provided | ||
@@ -251,2 +258,5 @@ if (obj === null || typeof obj === 'undefined') { | ||
let i; | ||
let l; | ||
// Force an array if not already something iterable | ||
@@ -260,3 +270,3 @@ if (typeof obj !== 'object') { | ||
// Iterate over array values | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
for (i = 0, l = obj.length; i < l; i++) { | ||
fn.call(null, obj[i], i, obj); | ||
@@ -266,6 +276,9 @@ } | ||
// Iterate over object keys | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
fn.call(null, obj[key], key, obj); | ||
} | ||
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); | ||
} | ||
@@ -275,2 +288,24 @@ } | ||
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; | ||
/** | ||
@@ -291,20 +326,23 @@ * 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, ... */) { | ||
var result = {}; | ||
function assignValue(val, key) { | ||
if (isPlainObject(result[key]) && isPlainObject(val)) { | ||
result[key] = merge(result[key], val); | ||
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); | ||
} else if (isPlainObject(val)) { | ||
result[key] = merge({}, val); | ||
result[targetKey] = merge({}, val); | ||
} else if (isArray(val)) { | ||
result[key] = val.slice(); | ||
result[targetKey] = val.slice(); | ||
} else { | ||
result[key] = val; | ||
result[targetKey] = val; | ||
} | ||
} | ||
for (var i = 0, l = arguments.length; i < l; i++) { | ||
forEach(arguments[i], assignValue); | ||
for (let i = 0, l = arguments.length; i < l; i++) { | ||
arguments[i] && forEach(arguments[i], assignValue); | ||
} | ||
@@ -320,7 +358,9 @@ return result; | ||
* @param {Object} thisArg The object to bind function to | ||
* @return {Object} The resulting value of object a | ||
* | ||
* @param {Boolean} [allOwnKeys] | ||
* @returns {Object} The resulting value of object a | ||
*/ | ||
function extend(a, b, thisArg) { | ||
forEach(b, function assignValue(val, key) { | ||
if (thisArg && typeof val === 'function') { | ||
const extend = (a, b, thisArg, {allOwnKeys}= {}) => { | ||
forEach(b, (val, key) => { | ||
if (thisArg && isFunction(val)) { | ||
a[key] = bind(val, thisArg); | ||
@@ -330,3 +370,3 @@ } else { | ||
} | ||
}); | ||
}, {allOwnKeys}); | ||
return a; | ||
@@ -339,5 +379,6 @@ } | ||
* @param {string} content with BOM | ||
* @return {string} content value without BOM | ||
* | ||
* @returns {string} content value without BOM | ||
*/ | ||
function stripBOM(content) { | ||
const stripBOM = (content) => { | ||
if (content.charCodeAt(0) === 0xFEFF) { | ||
@@ -349,25 +390,358 @@ content = content.slice(1); | ||
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 | ||
/** | ||
* Inherit the prototype methods from one constructor into another | ||
* @param {function} constructor | ||
* @param {function} superConstructor | ||
* @param {object} [props] | ||
* @param {object} [descriptors] | ||
* | ||
* @returns {void} | ||
*/ | ||
const 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); | ||
} | ||
/** | ||
* Resolve object with deep prototype chain to a flat object | ||
* @param {Object} sourceObj source object | ||
* @param {Object} [destObj] | ||
* @param {Function|Boolean} [filter] | ||
* @param {Function} [propFilter] | ||
* | ||
* @returns {Object} | ||
*/ | ||
const toFlatObject = (sourceObj, destObj, filter, propFilter) => { | ||
let props; | ||
let i; | ||
let prop; | ||
const merged = {}; | ||
destObj = destObj || {}; | ||
// eslint-disable-next-line no-eq-null,eqeqeq | ||
if (sourceObj == null) return destObj; | ||
do { | ||
props = Object.getOwnPropertyNames(sourceObj); | ||
i = props.length; | ||
while (i-- > 0) { | ||
prop = props[i]; | ||
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) { | ||
destObj[prop] = sourceObj[prop]; | ||
merged[prop] = true; | ||
} | ||
} | ||
sourceObj = filter !== false && getPrototypeOf(sourceObj); | ||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); | ||
return destObj; | ||
} | ||
/** | ||
* 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) => { | ||
str = String(str); | ||
if (position === undefined || position > str.length) { | ||
position = str.length; | ||
} | ||
position -= searchString.length; | ||
const lastIndex = str.indexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
} | ||
/** | ||
* Returns new array from array like object or null if failed | ||
* | ||
* @param {*} [thing] | ||
* | ||
* @returns {?Array} | ||
*/ | ||
const 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); | ||
while (i-- > 0) { | ||
arr[i] = thing[i]; | ||
} | ||
return arr; | ||
} | ||
/** | ||
* 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 => { | ||
// eslint-disable-next-line func-names | ||
return thing => { | ||
return TypedArray && thing instanceof TypedArray; | ||
}; | ||
})(typeof Uint8Array !== 'undefined' && 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; | ||
} | ||
); | ||
}; | ||
/* 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) => { | ||
let ret; | ||
if ((ret = reducer(descriptor, name, obj)) !== false) { | ||
reducedDescriptors[name] = ret || 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 | ||
}; |
203
package.json
{ | ||
"name": "axios", | ||
"version": "0.21.3", | ||
"version": "1.6.0", | ||
"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" | ||
} | ||
}, | ||
"./lib/adapters/http.js": "./lib/adapters/http.js", | ||
"./lib/adapters/xhr.js": "./lib/adapters/xhr.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": "grunt test", | ||
"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", | ||
"start": "node ./sandbox/server.js", | ||
"build": "NODE_ENV=production grunt build", | ||
"preversion": "npm test", | ||
"version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json", | ||
"postversion": "git push && git push --tags", | ||
"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", | ||
"examples": "node ./examples/server.js", | ||
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"fix": "eslint --fix lib/**/*.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" | ||
}, | ||
@@ -35,21 +83,39 @@ "repository": { | ||
"devDependencies": { | ||
"coveralls": "^3.0.0", | ||
"es6-promise": "^4.2.4", | ||
"grunt": "^1.3.0", | ||
"grunt-banner": "^0.6.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.1.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-eslint": "^23.0.0", | ||
"grunt-karma": "^4.0.0", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-ts": "^6.0.0-beta.19", | ||
"grunt-webpack": "^4.0.2", | ||
"istanbul-instrumenter-loader": "^1.0.0", | ||
"@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", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^6.3.2", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma": "^6.3.17", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-jasmine": "^1.1.1", | ||
"karma-jasmine-ajax": "^0.1.13", | ||
"karma-rollup-preprocessor": "^7.0.8", | ||
"karma-safari-launcher": "^1.0.0", | ||
@@ -59,15 +125,21 @@ "karma-sauce-launcher": "^4.3.6", | ||
"karma-sourcemap-loader": "^0.3.8", | ||
"karma-webpack": "^4.0.2", | ||
"load-grunt-tasks": "^3.5.2", | ||
"minimist": "^1.2.0", | ||
"mocha": "^8.2.1", | ||
"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", | ||
"sinon": "^4.5.0", | ||
"stream-throttle": "^0.1.3", | ||
"string-replace-async": "^3.0.2", | ||
"terser-webpack-plugin": "^4.2.3", | ||
"typescript": "^4.0.5", | ||
"url-search-params": "^0.10.0", | ||
"webpack": "^4.44.2", | ||
"webpack-dev-server": "^3.11.0" | ||
"typescript": "^4.8.4" | ||
}, | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js" | ||
"./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" | ||
}, | ||
@@ -78,3 +150,5 @@ "jsdelivr": "dist/axios.min.js", | ||
"dependencies": { | ||
"follow-redirects": "^1.14.0" | ||
"follow-redirects": "^1.15.0", | ||
"form-data": "^4.0.0", | ||
"proxy-from-env": "^1.1.0" | ||
}, | ||
@@ -86,3 +160,62 @@ "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" | ||
] | ||
} | ||
} |
938
README.md
@@ -1,17 +0,33 @@ | ||
# axios | ||
<h1 align="center"> | ||
<b> | ||
<a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br> | ||
</b> | ||
</h1> | ||
<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://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) | ||
[![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) | ||
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/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) | ||
[![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) | ||
[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) | ||
[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios) | ||
[![Known Vulnerabilities](https://snyk.io/test/npm/axios/badge.svg)](https://snyk.io/test/npm/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 | ||
@@ -22,6 +38,8 @@ | ||
- [Installing](#installing) | ||
- [Package manager](#package-manager) | ||
- [CDN](#cdn) | ||
- [Example](#example) | ||
- [Axios API](#axios-api) | ||
- [Request method aliases](#request-method-aliases) | ||
- [Concurrency (Deprecated)](#concurrency-deprecated) | ||
- [Concurrency π](#concurrency-deprecated) | ||
- [Creating an instance](#creating-an-instance) | ||
@@ -36,9 +54,19 @@ - [Instance methods](#instance-methods) | ||
- [Interceptors](#interceptors) | ||
- [Multiple Interceptors](#multiple-interceptors) | ||
- [Handling Errors](#handling-errors) | ||
- [Cancellation](#cancellation) | ||
- [AbortController](#abortcontroller) | ||
- [CancelToken π](#canceltoken-deprecated) | ||
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format) | ||
- [Browser](#browser) | ||
- [Node.js](#nodejs) | ||
- [Query string](#query-string) | ||
- [Form data](#form-data) | ||
- [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) | ||
- [π AxiosHeaders](#-axiosheaders) | ||
- [Semver](#semver) | ||
@@ -54,3 +82,3 @@ - [Promises](#promises) | ||
- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser | ||
- Make [http](http://nodejs.org/api/http.html) requests from node.js | ||
- Make [http](https://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 | ||
@@ -60,8 +88,9 @@ - Intercept request and response | ||
- Cancel requests | ||
- Automatic transforms for JSON data | ||
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) | ||
- 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) | ||
## Browser Support | ||
![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) | | ||
![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) | | ||
--- | --- | --- | --- | --- | --- | | ||
@@ -74,2 +103,4 @@ Latest β | Latest β | Latest β | Latest β | Latest β | 11 β | | ||
### Package manager | ||
Using npm: | ||
@@ -93,30 +124,61 @@ | ||
Using jsDelivr CDN: | ||
Using pnpm: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | ||
```bash | ||
$ pnpm add axios | ||
``` | ||
Using unpkg CDN: | ||
Once the package is installed, you can import the library using `import` or `require` approach: | ||
```html | ||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
```js | ||
import axios, {isCancel, AxiosError} from 'axios'; | ||
``` | ||
## Example | ||
You can also use the default export, since the named export is just a re-export from the Axios factory: | ||
### 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'; | ||
console.log(axios.isCancel('something')); | ||
```` | ||
If you use `require` for importing, **only default export is available**: | ||
```js | ||
const axios = require('axios').default; | ||
const axios = require('axios'); | ||
// axios.<method> will now provide autocomplete and parameter typings | ||
console.log(axios.isCancel('something')); | ||
``` | ||
Performing a `GET` request | ||
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: | ||
```js | ||
const axios = require('axios'); | ||
const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017) | ||
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017) | ||
``` | ||
### 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 | ||
@@ -132,3 +194,3 @@ axios.get('/user?ID=12345') | ||
}) | ||
.then(function () { | ||
.finally(function () { | ||
// always executed | ||
@@ -149,5 +211,5 @@ }); | ||
}) | ||
.then(function () { | ||
.finally(function () { | ||
// always executed | ||
}); | ||
}); | ||
@@ -165,3 +227,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. | ||
@@ -224,3 +286,3 @@ | ||
method: 'get', | ||
url: 'http://bit.ly/2mTM3nY', | ||
url: 'https://bit.ly/2mTM3nY', | ||
responseType: 'stream' | ||
@@ -242,3 +304,3 @@ }) | ||
For convenience aliases have been provided for all supported request methods. | ||
For convenience, aliases have been provided for all common request methods. | ||
@@ -337,7 +399,14 @@ ##### axios.request(config) | ||
}, | ||
// `paramsSerializer` is an optional config that allows you to customize serializing `params`. | ||
paramsSerializer: { | ||
// `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'}) | ||
//Custom encoder function which sends key/value pairs in an iterative fashion. | ||
encode?: (param: string): string => { /* Do custom operations here and return transformed string */ }, | ||
// Custom serializer function for the entire parameter. Allows user to mimic pre 1.x behaviour. | ||
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), | ||
//Configuration for formatting array indexes in the params. | ||
indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes). | ||
}, | ||
@@ -350,7 +419,7 @@ | ||
// - Browser only: FormData, File, Blob | ||
// - Node only: Stream, Buffer | ||
// - Node only: Stream, Buffer, FormData (form-data package) | ||
data: { | ||
firstName: 'Fred' | ||
}, | ||
// syntax alternative to send data into the body | ||
@@ -401,11 +470,11 @@ // method post | ||
// `onUploadProgress` allows handling of progress events for uploads | ||
// browser only | ||
onUploadProgress: function (progressEvent) { | ||
// Do whatever you want with the native progress event | ||
// browser & node.js | ||
onUploadProgress: function ({loaded, total, progress, bytes, estimated, rate, upload = true}) { | ||
// Do whatever you want with the Axios progress event | ||
}, | ||
// `onDownloadProgress` allows handling of progress events for downloads | ||
// browser only | ||
onDownloadProgress: function (progressEvent) { | ||
// Do whatever you want with the native progress event | ||
// browser & node.js | ||
onDownloadProgress: function ({loaded, total, progress, bytes, estimated, rate, download = true}) { | ||
// Do whatever you want with the Axios progress event | ||
}, | ||
@@ -429,4 +498,15 @@ | ||
// If set to 0, no redirects will be followed. | ||
maxRedirects: 5, // default | ||
maxRedirects: 21, // default | ||
// `beforeRedirect` defines a function that will be called before redirect. | ||
// Use this to adjust the request options upon redirecting, | ||
// to inspect the latest response headers, | ||
// or to cancel the request by throwing an error | ||
// If maxRedirects is set to 0, `beforeRedirect` is not used. | ||
beforeRedirect: (options, { headers }) => { | ||
if (options.hostname === "example.com") { | ||
options.auth = "user:password"; | ||
} | ||
}, | ||
// `socketPath` defines a UNIX Socket to be used in node.js. | ||
@@ -437,2 +517,5 @@ // e.g. '/var/run/docker.sock' to send requests to the docker daemon. | ||
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 | ||
@@ -455,6 +538,7 @@ // `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, | ||
@@ -472,8 +556,19 @@ auth: { | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// an alternative way to cancel Axios requests using AbortController | ||
signal: new AbortController().signal, | ||
// `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 | ||
// - Node only (XHR cannot turn off decompression) | ||
decompress: true, // default | ||
decompress: true // default | ||
// `insecureHTTPParser` boolean. | ||
// Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers. | ||
// This may allow interoperability with non-conformant HTTP implementations. | ||
// Using the insecure parser should be avoided. | ||
// see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback | ||
// see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none | ||
insecureHTTPParser: undefined // default | ||
// transitional options for backward compatibility that may be removed in the newer versions | ||
@@ -487,7 +582,25 @@ transitional: { | ||
// try to parse the response string as JSON even if `responseType` is not 'json' | ||
forcedJSONParsing: true; | ||
forcedJSONParsing: true, | ||
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | ||
clarifyTimeoutError: false, | ||
} | ||
}, | ||
env: { | ||
// The FormData class to be used to automatically serialize the payload into a FormData object | ||
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 | ||
] | ||
} | ||
@@ -512,3 +625,3 @@ ``` | ||
// `headers` the HTTP headers that the server responded with | ||
// All header names are lower cased and can be accessed using the bracket notation. | ||
// All header names are lowercase and can be accessed using the bracket notation. | ||
// Example: `response.headers['content-type']` | ||
@@ -572,3 +685,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.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/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. | ||
@@ -623,2 +736,11 @@ ```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. | ||
@@ -632,3 +754,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 | ||
@@ -644,3 +766,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 | ||
@@ -661,4 +783,51 @@ of `runWhen` is `false`. The function will be called with the config | ||
### Multiple Interceptors | ||
Given you add multiple response interceptors | ||
and when the response was fulfilled | ||
- then each interceptor is executed | ||
- then they are executed in the order they were added | ||
- then only the last interceptor's result is returned | ||
- then every interceptor receives the result of its predecessor | ||
- and when the fulfillment-interceptor throws | ||
- then the following fulfillment-interceptor is not called | ||
- then the following rejection-interceptor is 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. | ||
## Error Types | ||
There are many different axios error messages that can appear that can provide basic information about the specifics of the error and where opportunities may lie in debugging. | ||
The general structure of axios errors is as follows: | ||
| Property | Definition | | ||
| -------- | ---------- | | ||
| message | A quick summary of the error message and the status it failed with. | | ||
| name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. | | ||
| stack | Provides the stack trace of the error. | | ||
| config | An axios config object with specific instance configurations defined by the user from when the request was made | | ||
| code | Represents an axios identified error. The table below lists out specific definitions for internal axios error. | | ||
| status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings. | ||
Below is a list of potential axios identified error | ||
| Code | Definition | | ||
| -------- | ---------- | | ||
| ERR_BAD_OPTION_VALUE | Invalid or unsupported value provided in axios configuration. | | ||
| ERR_BAD_OPTION | Invalid option provided in axios configuration. | | ||
| ECONNABORTED | Request timed out due to exceeding timeout specified in axios configuration. | | ||
| ETIMEDOUT | Request timed out due to exceeding default axios timelimit. | | ||
| ERR_NETWORK | Network-related issue. | ||
| ERR_FR_TOO_MANY_REDIRECTS | Request is redirected too many times; exceeds max redirects specified in axios configuration. | ||
| ERR_DEPRECATED | Deprecated feature or method used in axios. | ||
| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. | ||
| ERR_BAD_REQUEST | Requested has unexpected format or missing required parameters. | | ||
| ERR_CANCELED | Feature or method is canceled explicitly by the user. | ||
| ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment. | ||
| ERR_INVALID_URL | Invalid URL provided for axios request. | ||
## Handling Errors | ||
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 | ||
@@ -686,3 +855,3 @@ axios.get('/user/12345') | ||
Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error. | ||
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. | ||
@@ -708,6 +877,26 @@ ```js | ||
You can cancel a request using a *cancel token*. | ||
### AbortController | ||
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
Starting from `v0.22.0` Axios supports AbortController to cancel requests in fetch API way: | ||
```js | ||
const controller = new AbortController(); | ||
axios.get('/foo/bar', { | ||
signal: controller.signal | ||
}).then(function(response) { | ||
//... | ||
}); | ||
// cancel the request | ||
controller.abort() | ||
``` | ||
### CancelToken `πdeprecated` | ||
You can also cancel a request using a *CancelToken*. | ||
> The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
> This API is deprecated since v0.22.0 and shouldn't be used in new projects | ||
You can create a cancel token using the `CancelToken.source` factory as shown below: | ||
@@ -756,22 +945,23 @@ | ||
> Note: you can cancel several requests with the same cancel token. | ||
> 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. | ||
> **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. | ||
## Using application/x-www-form-urlencoded format | ||
> During the transition period, you can use both cancellation APIs, even for the same request: | ||
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. | ||
## Using `application/x-www-form-urlencoded` format | ||
### Browser | ||
### URLSearchParams | ||
In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: | ||
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). | ||
```js | ||
const params = new URLSearchParams(); | ||
params.append('param1', 'value1'); | ||
params.append('param2', 'value2'); | ||
const params = new URLSearchParams({ foo: 'bar' }); | ||
params.append('extraparam', 'value'); | ||
axios.post('/foo', params); | ||
``` | ||
> 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). | ||
### Query string (Older browsers) | ||
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: | ||
@@ -798,28 +988,78 @@ | ||
### Node.js | ||
### Older Node.js versions | ||
#### Query string | ||
For older Node.js engines, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
```js | ||
const querystring = require('querystring'); | ||
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); | ||
axios.post('https://something.com/', querystring.stringify({ foo: 'bar' })); | ||
``` | ||
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows: | ||
You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
> **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 url = require('url'); | ||
const params = new url.URLSearchParams({ foo: 'bar' }); | ||
axios.post('http://something.com/', params.toString()); | ||
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'}} | ||
); | ||
``` | ||
You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
The server will handle it as: | ||
###### NOTE | ||
The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665). | ||
```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' | ||
} | ||
```` | ||
#### Form data | ||
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 | ||
```js | ||
var app = express(); | ||
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: | ||
@@ -829,3 +1069,3 @@ | ||
const FormData = require('form-data'); | ||
const form = new FormData(); | ||
@@ -836,16 +1076,505 @@ form.append('my_field', 'my value'); | ||
axios.post('https://example.com', form, { headers: form.getHeaders() }) | ||
axios.post('https://example.com', form) | ||
``` | ||
Alternatively, use an interceptor: | ||
### π Automatic serialization to FormData | ||
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`. | ||
The following request will submit the data in a FormData format (Browser & Node.js): | ||
```js | ||
axios.interceptors.request.use(config => { | ||
if (config.data instanceof FormData) { | ||
Object.assign(config.headers, config.data.getHeaders()); | ||
import axios from 'axios'; | ||
axios.post('https://httpbin.org/post', {x: 1}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
return config; | ||
}).then(({data}) => console.log(data)); | ||
``` | ||
In the `node.js` build, the ([`form-data`](https://github.com/form-data/form-data)) polyfill is used by default. | ||
You can overload the FormData class by setting the `env.FormData` config variable, | ||
but you probably won't need it in most cases: | ||
```js | ||
const axios = require('axios'); | ||
var FormData = require('form-data'); | ||
axios.post('https://httpbin.org/post', {x: 1, buf: new Buffer(10)}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}).then(({data}) => console.log(data)); | ||
``` | ||
Axios FormData serializer supports some special endings to perform the following operations: | ||
- `{}` - serialize the value with JSON.stringify | ||
- `[]` - 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}] | ||
}; | ||
``` | ||
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 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`. | ||
## Files Posting | ||
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[]`. | ||
## π HTML Form Posting (browser) | ||
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')); | ||
``` | ||
`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' | ||
} | ||
}) | ||
``` | ||
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 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 | ||
}); | ||
``` | ||
## π AxiosHeaders | ||
Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work. | ||
Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons | ||
and for a workaround when servers mistakenly consider the header's case. | ||
The old approach of directly manipulating headers object is still available, but deprecated and not recommended for future usage. | ||
### Working with headers | ||
An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic. | ||
The final headers object with string values is obtained by Axios by calling the `toJSON` method. | ||
> Note: By JSON here we mean an object consisting only of string values intended to be sent over the network. | ||
The header value can be one of the following types: | ||
- `string` - normal string value that will be sent to the server | ||
- `null` - skip header when rendering to JSON | ||
- `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true` | ||
to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`) | ||
- `undefined` - value is not set | ||
> Note: The header value is considered set if it is not equal to undefined. | ||
The headers object is always initialized inside interceptors and transformers: | ||
```ts | ||
axios.interceptors.request.use((request: InternalAxiosRequestConfig) => { | ||
request.headers.set('My-header', 'value'); | ||
request.headers.set({ | ||
"My-set-header1": "my-set-value1", | ||
"My-set-header2": "my-set-value2" | ||
}); | ||
request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios | ||
request.headers.setContentType('text/plain'); | ||
request.headers['My-set-header2'] = 'newValue' // direct access is deprecated | ||
return request; | ||
} | ||
); | ||
```` | ||
You can iterate over an `AxiosHeaders` instance using a `for...of` statement: | ||
````js | ||
const headers = new AxiosHeaders({ | ||
foo: '1', | ||
bar: '2', | ||
baz: '3' | ||
}); | ||
for(const [header, value] of headers) { | ||
console.log(header, value); | ||
} | ||
// foo 1 | ||
// bar 2 | ||
// baz 3 | ||
```` | ||
### new AxiosHeaders(headers?) | ||
Constructs a new `AxiosHeaders` instance. | ||
``` | ||
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string); | ||
``` | ||
If the headers object is a string, it will be parsed as RAW HTTP headers. | ||
````js | ||
const headers = new AxiosHeaders(` | ||
Host: www.bing.com | ||
User-Agent: curl/7.54.0 | ||
Accept: */*`); | ||
console.log(headers); | ||
// Object [AxiosHeaders] { | ||
// host: 'www.bing.com', | ||
// 'user-agent': 'curl/7.54.0', | ||
// accept: '*/*' | ||
// } | ||
```` | ||
### AxiosHeaders#set | ||
```ts | ||
set(headerName, value: Axios, rewrite?: boolean); | ||
set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean); | ||
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean); | ||
``` | ||
The `rewrite` argument controls the overwriting behavior: | ||
- `false` - do not overwrite if header's value is set (is not `undefined`) | ||
- `undefined` (default) - overwrite the header unless its value is set to `false` | ||
- `true` - rewrite anyway | ||
The option can also accept a user-defined function that determines whether the value should be overwritten or not. | ||
Returns `this`. | ||
### AxiosHeaders#get(header) | ||
``` | ||
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue; | ||
get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
```` | ||
Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`, | ||
matcher function or internal key-value parser. | ||
```ts | ||
const headers = new AxiosHeaders({ | ||
'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h' | ||
}); | ||
console.log(headers.get('Content-Type')); | ||
// multipart/form-data; boundary=Asrf456BGe4h | ||
console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters: | ||
// [Object: null prototype] { | ||
// 'multipart/form-data': undefined, | ||
// boundary: 'Asrf456BGe4h' | ||
// } | ||
console.log(headers.get('Content-Type', (value, name, headers) => { | ||
return String(value).replace(/a/g, 'ZZZ'); | ||
})); | ||
// multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h | ||
console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]); | ||
// boundary=Asrf456BGe4h | ||
``` | ||
Returns the value of the header. | ||
### AxiosHeaders#has(header, matcher?) | ||
``` | ||
has(header: string, matcher?: AxiosHeaderMatcher): boolean; | ||
``` | ||
Returns `true` if the header is set (has no `undefined` value). | ||
### AxiosHeaders#delete(header, matcher?) | ||
``` | ||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; | ||
``` | ||
Returns `true` if at least one header has been removed. | ||
### AxiosHeaders#clear(matcher?) | ||
``` | ||
clear(matcher?: AxiosHeaderMatcher): boolean; | ||
``` | ||
Removes all headers. | ||
Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value. | ||
```ts | ||
const headers = new AxiosHeaders({ | ||
'foo': '1', | ||
'x-foo': '2', | ||
'x-bar': '3', | ||
}); | ||
console.log(headers.clear(/^x-/)); // true | ||
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' } | ||
``` | ||
Returns `true` if at least one header has been cleared. | ||
### AxiosHeaders#normalize(format); | ||
If the headers object was changed directly, it can have duplicates with the same name but in different cases. | ||
This method normalizes the headers object by combining duplicate keys into one. | ||
Axios uses this method internally after calling each interceptor. | ||
Set `format` to true for converting headers name to lowercase and capitalize the initial letters (`cOntEnt-type` => `Content-Type`) | ||
```js | ||
const headers = new AxiosHeaders({ | ||
'foo': '1', | ||
}); | ||
headers.Foo = '2'; | ||
headers.FOO = '3'; | ||
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' } | ||
console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' } | ||
console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' } | ||
``` | ||
Returns `this`. | ||
### AxiosHeaders#concat(...targets) | ||
``` | ||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
``` | ||
Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers. | ||
Returns a new `AxiosHeaders` instance. | ||
### AxiosHeaders#toJSON(asStrings?) | ||
```` | ||
toJSON(asStrings?: boolean): RawAxiosHeaders; | ||
```` | ||
Resolve all internal headers values into a new null prototype object. | ||
Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas. | ||
### AxiosHeaders.from(thing?) | ||
```` | ||
from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; | ||
```` | ||
Returns a new `AxiosHeaders` instance created from the raw headers passed in, | ||
or simply returns the given headers object if it's an `AxiosHeaders` instance. | ||
### AxiosHeaders.concat(...targets) | ||
```` | ||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
```` | ||
Returns a new `AxiosHeaders` instance created by merging the target objects. | ||
### Shortcuts | ||
The following shortcuts are available: | ||
- `setContentType`, `getContentType`, `hasContentType` | ||
- `setContentLength`, `getContentLength`, `hasContentLength` | ||
- `setAccept`, `getAccept`, `hasAccept` | ||
- `setUserAgent`, `getUserAgent`, `hasUserAgent` | ||
- `setContentEncoding`, `getContentEncoding`, `hasContentEncoding` | ||
## Semver | ||
@@ -857,3 +1586,3 @@ | ||
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). | ||
axios depends on a native ES6 Promise implementation to be [supported](https://caniuse.com/promises). | ||
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). | ||
@@ -863,3 +1592,3 @@ | ||
axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors. | ||
axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors. | ||
@@ -880,7 +1609,13 @@ ```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/master/examples/server.js) | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js) | ||
@@ -890,11 +1625,10 @@ | ||
* [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) | ||
* [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) | ||
## Credits | ||
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. | ||
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [AngularJS](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of AngularJS. | ||
@@ -901,0 +1635,0 @@ ## License |
@@ -1,5 +0,6 @@ | ||
# Security Policy | ||
# Reporting a Vulnerability | ||
## Reporting a Vulnerability | ||
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. | ||
Please report security issues to jasonsaayman@gmail.com | ||
Thank you for improving the security of axios. |
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
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
1785881
80
16476
0
1603
0
Yes
3
55
4
+ Addedform-data@^4.0.0
+ Addedproxy-from-env@^1.1.0
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
Updatedfollow-redirects@^1.15.0