Skip to content

Conversation

TNAJanssen
Copy link

Summary

This PR migrates the codebase from axios to the native fetch API, removing the external dependency while
maintaining all existing functionality.

Changes Made

🔧 Core Migration

  • Removed axios dependency from package.json
  • Created fetch wrapper (src/fetchUtils.js) with:
    • Custom error handling with FetchError class
    • isAbortError() helper for cancellation detection
    • Response interceptor pattern for retry logic
    • Automatic content-type handling

🔄 Request Cancellation

  • Replaced axios.CancelToken with native AbortController
  • Updated all React hooks to use AbortController for cleanup
  • Maintains proper request cancellation on component unmount

🔁 Retry Logic

  • Preserved automatic retry behavior for Dymo service discovery
  • Continues scanning ports 41951-41953 on both 127.0.0.1 and localhost
  • Maintains localStorage caching of successful connection parameters
  • Skips retry on HTTP 500 errors and aborted requests (same as before)

📝 Additional Fixes

  • Fixed missing moment.js import in storage.js by removing unused expiration logic (separate commit)

Testing

  • ✅ Build passes without errors
  • ✅ ESLint passes without warnings
  • ✅ All existing APIs maintain the same interface
  • ⚠️ Manual testing with Dymo hardware recommended

Breaking Changes

None - the API remains identical for consumers of this library.

Browser Compatibility

The fetch API and AbortController are well-supported in modern browsers. For older browser support, polyfills may
be needed.

Alexander Janssen added 2 commits July 31, 2025 09:57
The expiration parameter was always null and the moment library was not imported.
Simplified storage utilities to basic localStorage get/set operations.
- Replace axios with native fetch API throughout the codebase
- Implement custom fetch wrapper with retry logic and AbortController support
- Maintain same retry behavior for Dymo service port scanning (41951-41953)
- Replace CancelToken with AbortController for request cancellation
- Remove axios dependency from package.json
- All existing functionality preserved with native browser APIs
@apenab
Copy link
Owner

apenab commented Aug 5, 2025

Hi @TNAJanssen , thx for the contribution, I'll try to review the PR ASAP.

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.

2 participants