-
Notifications
You must be signed in to change notification settings - Fork 562
refactor(drivers): replace axios with native fetch API #25592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6284ad5 to
03ef6f4
Compare
packages/service-clients/end-to-end-tests/azure-client/src/test/AzureClientFactory.ts
Show resolved
Hide resolved
packages/service-clients/end-to-end-tests/azure-client/src/test/tree.spec.ts
Outdated
Show resolved
Hide resolved
packages/service-clients/end-to-end-tests/azure-client/src/test/tree.spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors client libraries to replace axios with native fetch for HTTP requests, modernizing the HTTP client implementation and reducing dependencies.
- Removes axios dependency from multiple packages
- Replaces axios-based HTTP calls with fetch API
- Updates type definitions to use custom request types instead of axios types
Reviewed Changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/service-clients/end-to-end-tests/azure-client/src/test/viewContainerVersion.spec.ts | Removes axios import and type annotations |
| packages/service-clients/end-to-end-tests/azure-client/src/test/tree.spec.ts | Removes axios import, refactors tree imports, and updates API usage |
| packages/service-clients/end-to-end-tests/azure-client/src/test/signals.spec.ts | Removes axios import and type annotations |
| packages/service-clients/end-to-end-tests/azure-client/src/test/ddsTests.spec.ts | Removes axios import and type annotations |
| packages/service-clients/end-to-end-tests/azure-client/src/test/containerCreate.spec.ts | Removes axios import and SharedTree legacy import |
| packages/service-clients/end-to-end-tests/azure-client/src/test/audience.spec.ts | Removes axios import and type annotations |
| packages/service-clients/end-to-end-tests/azure-client/src/test/AzureClientFactory.ts | Replaces axios with fetch implementation and creates custom response types |
| packages/service-clients/end-to-end-tests/azure-client/package.json | Removes axios dependency |
| packages/loader/driver-utils/src/insecureUrlResolver.ts | Replaces axios with fetch for URL resolution |
| packages/loader/driver-utils/package.json | Removes axios dependency |
| packages/drivers/routerlicious-driver/src/restWrapperBase.ts | Updates type imports to use custom request types |
| packages/drivers/routerlicious-driver/src/restWrapper.ts | Replaces axios with fetch and updates type references |
| packages/drivers/routerlicious-driver/src/request.cts | Adds new custom request type definitions |
| packages/drivers/routerlicious-driver/src/axios.cts | Removes axios type re-exports |
| packages/drivers/routerlicious-driver/package.json | Removes axios dependency and reorganizes dependencies |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
packages/service-clients/end-to-end-tests/azure-client/src/test/tree.spec.ts
Outdated
Show resolved
Hide resolved
packages/service-clients/end-to-end-tests/azure-client/src/test/AzureClientFactory.ts
Show resolved
Hide resolved
Fetch doesn't automatically throw on non-2xx responses like axios did, so added explicit response.ok check before parsing JSON to ensure proper error handling.
packages/service-clients/end-to-end-tests/azure-client/src/test/AzureClientFactory.ts
Show resolved
Hide resolved
| // Fetch doesn't auto-throw on non-2xx responses like axios did, so check explicitly | ||
| if (!response.ok) { | ||
| throw new Error(`Error creating container. Status code: ${response.status}`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary over the previous approach? We were already explicitly throwing for any response code other than 201.
## Summary Replaces the axios HTTP client library with native `fetch` API across client-side packages to reduce bundle size and simplify dependencies. ## Changes ### Routerlicious Driver (`packages/drivers/routerlicious-driver`) - Replaced axios with native `fetch` via `cross-fetch` polyfill - Created `request.cts` with fetch-compatible type definitions (`RequestConfig`, `RequestHeaders`, `RawRequestHeaders`) that maintain API compatibility with server-side axios usage - Removed `axios.cts` re-export file - Moved `uuid` from runtime to dev dependencies (only used in tests) ### Driver Utils (`packages/loader/driver-utils`) - Updated `insecureUrlResolver.ts` to use native `fetch` instead of axios - Removed axios dependency from package.json ### Azure Client E2E Tests (`packages/service-clients/end-to-end-tests/azure-client`) - Refactored `AzureClientFactory.ts` to use native `fetch` - Introduced `FetchResponse` interface to replace `AxiosResponse` type - Updated response handling with explicit `response.ok` checks (fetch doesn't auto-throw on non-2xx) - Improved type safety in `getContainerIdFromPayloadResponse` with explicit type guards - Removed `AxiosResponse` type imports from all test files
Summary
Replaces the axios HTTP client library with native
fetchAPI across client-side packages to reduce bundle size and simplify dependencies.Changes
Routerlicious Driver (
packages/drivers/routerlicious-driver)fetchviacross-fetchpolyfillrequest.ctswith fetch-compatible type definitions (RequestConfig,RequestHeaders,RawRequestHeaders) that maintain API compatibility with server-side axios usageaxios.ctsre-export fileuuidfrom runtime to dev dependencies (only used in tests)Driver Utils (
packages/loader/driver-utils)insecureUrlResolver.tsto use nativefetchinstead of axiosAzure Client E2E Tests (
packages/service-clients/end-to-end-tests/azure-client)AzureClientFactory.tsto use nativefetchFetchResponseinterface to replaceAxiosResponsetyperesponse.okchecks (fetch doesn't auto-throw on non-2xx)getContainerIdFromPayloadResponsewith explicit type guardsAxiosResponsetype imports from all test files