refactor: replace axios and form-data with Node built-in fetch and FormData#124
Open
refactor: replace axios and form-data with Node built-in fetch and FormData#124
Conversation
…rmData Node >=20 provides fetch and FormData as globals, making the axios and form-data dependencies unnecessary. Streams are buffered internally before appending to FormData since the native API only accepts Blob/File/string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
2 tasks
moritzraho
approved these changes
Apr 2, 2026
mgar
approved these changes
Apr 2, 2026
dthampy
reviewed
Apr 2, 2026
…ateCredentialDirect - Pass 'certificate' as the filename when appending a Blob to FormData, avoiding the default "blob" filename that browsers/runtimes report - Check res.ok after fetch and throw a shaped error on non-2xx responses so callers retain the same error-path behaviour as the previous axios implementation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
axiosandform-dataproduction dependenciesaxios.request()with the Node built-infetch(global in Node >=20)form-datanpmFormDatawith the Node built-inFormData(global in Node >=20)Blobbefore appending toFormData, since the native API only acceptsBlob/File/string(not Node.jsReadablestreams) — preserving the existing public APIContent-Type: multipart/form-dataheader so the runtime sets it automatically with the correct multipart boundaryglobal.fetchviajest.spyOninstead ofjest.mock('axios')Test plan
npm test)npm run e2e(verified: Transporter API has some regressions but adapted to it)🤖 Generated with Claude Code