Skip to content

Replace axios with native fetch API#48

Merged
SCdF merged 3 commits intomainfrom
replace-axios-with-fetch
Jan 22, 2026
Merged

Replace axios with native fetch API#48
SCdF merged 3 commits intomainfrom
replace-axios-with-fetch

Conversation

@SCdF
Copy link
Owner

@SCdF SCdF commented Jan 22, 2026

Summary

  • Remove axios dependency and migrate all HTTP calls to native fetch API
  • Use AbortController for request timeouts (replacing axios.CancelToken)
  • Handle HTTP errors via response.ok checks instead of axios error throwing
  • Simplifies codebase by removing external dependency for straightforward HTTP operations

Files changed

  • About.tsx - Simple GET converted to fetch
  • UserAuthenticationWidget.tsx - POST/PUT with JSON body and error handling
  • UserProvider.tsx - GET with timeout using AbortController
  • SyncManager.tsx - Multiple POSTs with inline 401 handling

Test plan

  • yarn check passes
  • All 140 tests pass (109 client + 31 server)
  • Manual testing: login/signup flow
  • Manual testing: offline → online sync
  • Manual testing: server down scenarios
  • Manual testing: About page in production mode

🤖 Generated with Claude Code

SCdF and others added 3 commits January 21, 2026 20:04
Replace axios library mocking with MSW (Mock Service Worker) to intercept
HTTP requests at the network level. This prepares for replacing axios with
fetch, as MSW works with both.

- Add msw as dev dependency
- Create msw-handlers.ts with default API response handlers
- Create msw-server.ts to set up the test server
- Update test-setup.ts to start/stop MSW server
- Migrate UserProvider.test.tsx from axios mocks to MSW
- Migrate App.test.tsx from axios mocks to MSW
- Remove duplicate "unresponsive server" test (same behavior as network error)
- Add passthrough handler for socket.io polling requests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 2 of axios migration: Add comprehensive test coverage for components
that use HTTP calls before replacing axios with fetch.

- SyncManager.test.tsx: 10 tests covering sync flow, error handling, socket events
- UserAuthenticationWidget.test.tsx: 11 tests for login, signup, validation
- About.test.tsx: 2 tests for basic rendering
- Extended MockDatabase interface with info, changes, allDocs, bulkDocs methods
- Updated CLAUDE.md with guidance on magic numbers and type assertions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove axios dependency and migrate all HTTP calls to use the native
fetch API with AbortController for timeouts. This simplifies the
codebase by removing an external dependency for straightforward HTTP
operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@SCdF SCdF enabled auto-merge January 22, 2026 11:28
@SCdF SCdF merged commit de4f269 into main Jan 22, 2026
2 checks passed
@SCdF SCdF deleted the replace-axios-with-fetch branch January 22, 2026 11:28
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.

1 participant