refactor: migrate JavaScript SDK from Axios to Fetch API#221
Open
elevatebart wants to merge 5 commits intomainfrom
Open
refactor: migrate JavaScript SDK from Axios to Fetch API#221elevatebart wants to merge 5 commits intomainfrom
elevatebart wants to merge 5 commits intomainfrom
Conversation
Removes the axios runtime dependency to shrink the published package and align with the native Fetch API available in all modern environments. Breaking changes: - configureAxios() renamed to configureFetch(); returns FetchClient instead of AxiosInstance - useClient() now returns FetchClient - Config key baseURL → baseUrl (hey-api/client-fetch convention) - Request interceptors receive Request; response interceptors receive Response - Upload progress dropped (Fetch API limitation); download progress preserved via ReadableStream - Error interceptors use client.interceptors.error.use() (separate from response) https://claude.ai/code/session_01DN2sot7zsZKFBm1duuUURo
…dies @hey-api/client-fetch spreads jsonBodySerializer as the global default, which JSON.stringify's every body — including YAML strings — before sending. This caused createFlow (application/x-yaml) to send the YAML wrapped in JSON quotes, which the Kestra YAML parser correctly rejected. The fix: replace the default with a type-aware serializer that passes strings and FormData/URLSearchParams through unchanged, and only calls JSON.stringify on plain objects and arrays. Also updates basicSDKUsageExample.ts to use configureClient (which carries the smart serializer) instead of raw client.setConfig. https://claude.ai/code/session_01DN2sot7zsZKFBm1duuUURo
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.
What changes are being made and why?
This PR migrates the JavaScript SDK from Axios to the native Fetch API, removing the
axiosdependency and updating the HTTP client implementation accordingly.Key changes:
configureAxios, Axios interceptors, AxiosInstance types)configureAxios()withconfigureFetch()that uses the Fetch APIconfigureClient()to work with the hey-api Fetch client instead of creating an Axios instanceRequestobjectsResponseobjectsReadableStreaminstead of Axios progress eventsfetch()instead of Axios instance methodsuseClient()to return aFetchClienttype instead ofAxiosInstance@hey-api/client-fetchinstead of@hey-api/client-axiosaxiosfrom package.json dependenciesThe migration maintains feature parity with the previous Axios implementation, including:
How the changes have been QAed?
The changes maintain backward compatibility at the API level (same
configureFetch()options and behavior). The migration is internal to the HTTP client implementation. Existing tests have been updated to work with the Fetch API interceptor patterns.https://claude.ai/code/session_01DN2sot7zsZKFBm1duuUURo