Skip to content

Releases: L-Blondy/up-fetch

v2.0.0-beta.5

28 Feb 17:43
Compare
Choose a tag to compare
v2.0.0-beta.5 Pre-release
Pre-release

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 on up only.

Breaking changes

  • removal of deprecated options:
    • throwResponseError → rename to reject, available in 1.3.4
    • parseResponseError → rename to parseRejected, 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 the request instead of the options

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

28 Feb 17:47
Compare
Choose a tag to compare
  • fix pnpm module resolution issue #28

v1.3.5

28 Feb 20:26
Compare
Choose a tag to compare

Deprecations

In preparation for v2.0, the following options are now deprecated:

  • throwResponseError: use reject instead (100% compat)
  • parseResponseError: use parseRejected instead (100% compat)

v1.3.3

28 Feb 20:28
Compare
Choose a tag to compare

Fix

  • the default body type now accepts both types and interfaces #23

v1.3.0

28 Feb 20:30
Compare
Choose a tag to compare

Added

  • new isJsonifiable utility to determine if a value can be safely converted to json

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 the serializeBody 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,
    }))