Skip to content

Switch from axios/form-data to native fetch — zero production dependencies - #79

Merged
amaldona merged 2 commits into
mainfrom
copilot/consider-switching-to-native-fetch
Sep 15, 2026
Merged

amaldona merged 2 commits into
mainfrom
copilot/consider-switching-to-native-fetch

Conversation

Copilot AI commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

The SDK carried 27 transitive production dependencies via axios and form-data. All LTS Node.js versions (18+) ship native fetch, FormData, Blob, URLSearchParams, and AbortController, making both packages unnecessary.

Changes

  • lib/client/request.js

    • Replaced axios.request with native fetch; return shape preserved as { data } — no callers change
    • Replaced npm form-data with native FormData; Node.js ReadStream values are streamed to Buffer → Blob before appending (native FormData doesn't accept streams directly)
    • Content-Type header omitted for multipart requests so fetch sets the correct boundary automatically
    • Timeout implemented via AbortController + setTimeout (replaces axios timeout option)
    • Query params serialized with URLSearchParams (replaces axios params option)
  • package.json — axios and form-data removed from dependencies; SDK now has zero production runtime dependencies

// Before — 27 transitive deps
const axios = require('axios').default;
const FormData = require('form-data');

// After — no deps, same external behaviour
const controller = new AbortController();
const response = await fetch(api_url, { method, headers, body, signal: controller.signal });
return { data: await response.json() };

Co-authored-by: alejouribesanchez <3950665+alejouribesanchez@users.noreply.github.com>
Copilot AI changed the title [WIP] Switch to native fetch for HTTP requests Switch from axios/form-data to native fetch — zero production dependencies Sep 4, 2026
@draaglom

Copy link
Copy Markdown
Contributor

thanks for taking a look at this so quickly!

@alejouribesanchez
alejouribesanchez marked this pull request as ready for review September 15, 2026 18:28
@amaldona
amaldona merged commit 2a3585b into main Sep 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider switching to native fetch

5 participants