Releases: L-Blondy/up-fetch
v2.0.0-beta.5
Overview
This release introduces version 2 of up-fetch, focusing on simplifying the API and aligning more closely with web standards. The changes include removal of deprecated options and an update to callback signatures for better consistency with the Web Fetch API. These changes establish a more stable foundation that will make it easier to implement new features without breaking changes in the future.
Most users will not be affected by these changes, as they primarily impact advanced use cases and deprecated features. The core functionality of up-fetch remains unchanged, and the updates mainly focus on standardizing the API and removing legacy options.
Improvements
- Added lifecycle hooks on the
upfetch
instance. The lifecycle hooks were previously available onup
only.
Breaking changes
- removal of deprecated options:
throwResponseError
→ rename toreject
, available in 1.3.4parseResponseError
→ rename toparseRejected
, available in 1.3.4
- removal of the
options
object in order to align more closely with web standards and simplify the type system:- all callbacks (lifecycle hooks & parsers) now receive a
Request
object instead of resolved options. - the
ResponseError
receives therequest
instead of theoptions
- all callbacks (lifecycle hooks & parsers) now receive a
Check out the migration guide for more details.
Benefits
- Web Standards Alignment: Using the
Request
object aligns better with the Web Fetch API - Simpler Type System: Removing resolved options from callbacks reduces type complexity
- Improved Maintainability: Reduced API surface and more consistent behavior
- Future-Proof Architecture: The simplified and standardized API structure makes it easier to implement new features without breaking changes in the future
v1.3.6
v1.3.5
v1.3.3
v1.3.0
Added
- new
isJsonifiable
utility to determine if a value can be safely converted tojson
Breaking
-
The
serializeBody
option now receives any non nullish body as its first argument. Previously it received jsonifiable values only.The valid
body
type can now be restricted by typing theserializeBody
option's first argument.let upfetch = up(fetch, () => ({ // accept FormData only serializeBody: (body: FormData) => body, })) // ❌ type error: the body is not a FormData upfetch('https://example.com', { method: 'POST', body: { name: 'John' }, }) // ✅ works fine with FormData upfetch('https://example.com', { method: 'POST', body: new FormData(), })
-
upfetch's 2nd argument no longer has a functional signature.
Instead,up
receives the fetcher arguments to tailor the defaults based on the request.Example:
let upfetch = up(fetch, (input, options) => ({ baseUrl: 'https://example.com', timeout: typeof input === 'string' && input.startsWith('/export/') ? 30000 : 5000, }))