WIP: Fetch Adapter v2#5
Draft
sgammon wants to merge 69 commits into
Draft
Conversation
This changeset adds a `fetch`-based adapter implementation to `axios`, powered by `cross-fetch`[1]. The implementation may thus be used on either Node or in browser environments. Changes enclosed: - Add `fetch` adapter implementation - Add `fetch` to standard built-in adapters - Add initial Node-side tests for `fetch` - Slight refactor to tests to use common setup / teardown code Still pending: - Upload/download progress events - Browser-side testing Fixes and closes axios#1219, and supersedes axios#2891.
- Add support for `axios(URL(...))` and `axios({url: URL(...)})`
- Add config support for `fetcher`, `fetchOptions` and `parsedUrl`
- Translate `config.url = URL(...)` to string
- Implement override for `config.fetcher`
- Mock fetch implementation for testing - Spawn fetch adapter configs for testing - Test for expected instance/static props related to fetch adapter
- Add initial browser tests for fetch adapter - Test for acceptance of `URL`
- Add pure JS Node polyfill deps - Add new `generic` dist target for Workers, Deno, etc. - Move to typealiases in `lib/platform/...` rather than direct use - Adapt tests for new alias imports - Drop `cross-fetch`, any need for Node polyfills in pure JS envs
- Implement abstract testsuite structure for fetch - Move browser fetch tests to new implementation + API - Implement pure-JS test for Deno, based on new API - Add test command for Deno (`npm run test:deno`) - Add alias test command for Node (`npm run test:node`) - Add alias to run all tests (`npm run test:all`)
- Add basic fetch overhead benchmark - Add example using new `generic` output
- Define `knownAdapters` for each platform type - Import `knownAdapters` for library defaults - Alias XHR adapter to `#xhrAdapter`, only include in browser libs - Add `.generic.d.*ts` type entries which omit XHR adapter
Temporary: will probably drop before merge
- Setup baseline default and platform-specific `fetchOption`s - Avoids issue with some environments not supporting `cache` - Allows shipping bundles with reasonable defaults for each env
- Tweak treeshaking to be more aggressive on modern platforms - Move license comment to bottom of output targets
- Structured type for `FetchOptions` - Better type export for `Fetcher` - Better type export for `AxiosFetchAdapter`
- Add support for `beforeEach`/`afterEach` - Add full typings for abstract test types - Prep to extend abstract test suite to Node
- Skip checking config for handler type if no `responseType` param is present - Only resolve handler from `Content-Type` if header is available in response
- Move properties around to avoid stray changes in diffs - Move `cross-fetch` to optional deps
- Instead of failing, bypass URL parsing, and pass the URL verbatim to the underlying fetch implementation
- Move abstract fetch testsuite tests into basic test spec file
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
| <div> | ||
| <h3>User</h3> | ||
| <div class="row"> | ||
| <img id="useravatar" src="" class="col-md-1"/> |
There was a problem hiding this comment.
This image is missing a text alternative. This is a problem for people using screen readers.
sgammon
commented
Sep 14, 2023
Comment on lines
+27
to
+29
| - engine: bun | ||
| version: 0.3.0 | ||
| mode: labs |
Owner
Author
There was a problem hiding this comment.
test task missing for bun
Comment on lines
+24
to
+26
| - engine: node | ||
| version: 19.x | ||
| mode: labs |
Comment on lines
+1
to
+4
| # axios + fetch | ||
|
|
||
| This directory provides sample code for using Axios with the [Fetch API][1]. As of version `1.2.1`, Axios has a built-in | ||
| adapter for using `fetch` in environments that support it, and additionally supports use with Fetch API objects like |
Owner
Author
There was a problem hiding this comment.
maybe drop examples for another PR?
Comment on lines
+11
to
+13
| interface CommonHeaders { | ||
| common: AxiosHeaders; | ||
| } |
Comment on lines
+16
to
+19
| interface CommonHeaders { | ||
| common: AxiosHeaders; | ||
| } | ||
|
|
Owner
Author
|
There was a problem hiding this comment.
CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Coming soon, filed here for CI