react-dymo
react-dymo copied to clipboard
feat: Replace axios with native fetch API
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
FetchErrorclass isAbortError()helper for cancellation detection- Response interceptor pattern for retry logic
- Automatic content-type handling
- Custom error handling with
🔄 Request Cancellation
- Replaced
axios.CancelTokenwith nativeAbortController - Updated all React hooks to use
AbortControllerfor 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.jsby 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.
Hi @TNAJanssen , thx for the contribution, I'll try to review the PR ASAP.