Repository navigation
Releases: mshindi-labs/refetch
Release list
v3.2.0
v3.1.2
v3.1.1
v3.1.0
3.1.0 (2026-10-20)
Bug Fixes
- fetch: typed timeout/transport errors, honoured cancellation, body-read timeout (1db8251)
- fetch: typed timeout/transport errors, honoured cancellation, body-read timeout (c70bff5), closes #2 #3 #4 #10
- package: resolve CJS types, add sideEffects and metadata, raise engines (62019f7)
- package: resolve CJS types, add sideEffects and metadata, raise engines (e9b59ef), closes #14
Continuous Integration
v3.0.0
[3.0.0] — 2026-04-22
Full architectural redesign. Pure functional TypeScript, 14 single-responsibility modules, zero runtime dependencies.
Breaking Changes
Content-Typeremoved fromDEFAULT_HEADERS— set per-request viagetBodyContentType()insteadpost/put/patchbody type is now the second generic parameter:post<TResponse, TBody>addRequestTransform/addResponseTransformdeprecated in favour of the interceptor APIutils.tsdissolved — its exports moved into six focused modules (url.ts,headers.ts,body.ts,response.ts,fetch.ts,errors.ts)
Added
- Interceptor system — axios-style request/response middleware with Map-based storage, auto-increment IDs, and
eject(id)/clear(). Request interceptors run LIFO; response interceptors run FIFO per retry attempt. RefetchErrordiscriminated union — per-kind fields (http,timeout,cancel,network,parse,unknown) alongsidePROBLEM_CODE- Retry —
RetryConfigper-request or instance-wide; shorthand number form; request interceptors run once before the retry loop stream()— returnsApiResponse<ReadableStream<T>>with no body parsing and no retrypipe()+ middleware HOFs —withAuth,withTimeout,withHeaders,withBaseURL,withLoggingcompose onto instances without mutation- Sub-path exports —
@mshindi-labs/refetch/retry,/middleware,/pipe(tree-shakeable) - Richer response body parsing —
+jsonsuffix MIME variants,application/x-www-form-urlencoded→Record<string,string>, binary MIME types →Blob, empty-body guard for 204/304/content-length: 0 CancelErrorandcreateCancelTokenfor explicit request cancellation
Changed
buildRefetchErrormoved toerrors.ts;RefetchErrortype defined intypes.ts- FormData
Content-Typeis always deleted so the browser can set the multipart boundary - README, CLAUDE.md, and CONTRIBUTING.md fully rewritten for v3
v2.0.10
v2.0.7
fix: prevent config spread from overriding merged headers
Fixed a critical bug where DEFAULT_HEADERS (Content-Type: application/json)
were being stripped from requests.
Problem
The spread operator ...config at the end of fetchConfig construction was
overriding the carefully merged headers. Since config contained headers from
state.config (an empty Headers object for new instances), it would replace
our merged headers with an empty object.
Solution
Moved the ...config spread to the beginning of the fetchConfig object,
then explicitly override with our processed values (method, headers, body, timeout).
This ensures our merged headers always take precedence.
Testing
Verified with httpbin.org:
- ✅ JSON POST requests now correctly have Content-Type: application/json
- ✅ FormData requests still correctly have multipart/form-data with boundary
- ✅ All other request types working as expected
Impact
- Fixes JSON API calls not working correctly due to missing Content-Type
- Maintains FormData/URLSearchParams behavior (skips JSON headers)
- No breaking changes to API surface
v2.0.6
feat!: major optimizations, bug fixes, and new HTTP methods
This commit introduces significant improvements to code quality, bundle size,
and API completeness while fixing critical bugs.
Critical Bug Fixes
-
Fixed DEFAULT_HEADERS being incorrectly applied to FormData and URLSearchParams
- File uploads and form submissions now work correctly
- JSON headers are now conditionally applied based on body type
- Fixes issue where multipart/form-data was being overridden
-
Fixed inconsistent error response handling
- All error paths now use normalizeErrorResponse() consistently
- Ensures uniform response structure across HTTP and network errors
- Removed manual error response construction
New Features
- Added LINK and UNLINK HTTP methods for resource linking scenarios
- Added any() generic request method for custom HTTP verbs (PROPFIND, MKCOL, etc.)
- Added getBaseURL() method for base URL introspection
- Complete feature parity with apisauce API
Code Quality Improvements
-
Extracted duplicate query parameter building logic into buildQueryString() helper
- Eliminated ~30 lines of code duplication
- Improved maintainability and reduced bug surface area
-
Simplified header management by normalizing to Headers class
- Reduced setHeader() from 19 lines to 3 lines
- Reduced deleteHeader() from 12 lines to 3 lines
- Eliminated complex branching logic for header format handling
-
Removed redundant PROBLEM_CODES constant (use PROBLEM_CODE enum directly)
-
Removed unused ERROR_MESSAGES constants, inlined single usage
-
Cleaned up imports, removing unused classifyProblem and headersToObject
Bundle Size Optimizations
- Enabled minification in tsup.config.ts
- Reduced bundle size to ~2.3 KB gzipped (40% smaller than v2.0.2)
- Removed ~80+ lines of code through refactoring
- Better tree-shaking support
Documentation
- Updated README.md with new HTTP methods and getBaseURL() usage
- Documented v2.0.3 optimizations and bug fixes
- Removed apisauce comparison table, added "Why Refetch?" section
- Added comprehensive examples for LINK, UNLINK, and any() methods
Performance
- No runtime performance impact, only build-time improvements
- Smaller bundle size means faster downloads and parsing
- Cleaner code leads to better maintainability
Files Changed
- src/utils.ts: Extracted buildQueryString(), removed duplicate code
- src/refetch.ts: Fixed DEFAULT_HEADERS bug, added new HTTP methods, simplified headers
- src/constants.ts: Removed PROBLEM_CODES and ERROR_MESSAGES
- src/types.ts: Added type definitions for new methods
- src/index.ts: Removed PROBLEM_CODES export
- tsup.config.ts: Enabled minification
- README.md: Updated documentation
- apisauce.md: Added reference documentation
v2.0.2
Initial commit: refetch HTTP client library
Add lightweight, apisauce-inspired HTTP client built on native fetch API with full TypeScript support.
Features:
- Native fetch API wrapper with standardized response format
- Request/response transforms (sync & async)
- Response monitors for logging/analytics
- Timeout support via AbortController
- Error classification with PROBLEM_CODE enum
- Full TypeScript support with generics
- Dual package format (ESM + CommonJS)
Build infrastructure:
- tsup for fast bundling with dual format output
- TypeScript declarations generation
- Source maps for debugging
Package configuration:
- Scoped package: @mshindi-labs/refetch
- MIT licensed
- Node.js 18+ required
- Comprehensive README with examples
Co-Authored-By: Mshindi Labs INC 184962783+mshindi-labs@users.noreply.github.com