Skip to content

Releases: MattCCC/fetchff

v2.6.3

20 Aug 19:24
Compare
Choose a tag to compare

Features:

  • Parse additional media types in responses: +json / form-data, streams and FormData

Fixes:

  • Properly parse JSON responses with "+json" in Content-Type headers
  • Returned headers typings

PRs:

Full Changelog: v2.6.2...v2.6.3

v2.6.2

11 Aug 23:50
Compare
Choose a tag to compare

Fixes:

  • Request handler should handle the case of URLSearchParams passed properly
  • All native fetch information should be propagated to the extended response object
  • Fixed TS error when passing "body" to fetchf() without calling JSON.stringify()

What's Changed:

  • Propagate full response of native fetch to output by @MattCCC in #42

Full Changelog: v2.6.1...v2.6.2

v2.6.1

09 Aug 20:24
Compare
Choose a tag to compare

What's Changed

  • Typings improvements + remove axios by @MattCCC in #41

Full Changelog: v2.6.0...v2.6.1

v2.6.0

08 Aug 20:49
Compare
Choose a tag to compare

Features:

  • Improve error logging by adding request URL when error is thrown
  • New error handling strategy "softFail" - will return response object with additional "error" and other data in one object, without throwing (no try-catch required)
    Note that data and error can exist at the same time. So the UI can display the existing data, while knowing the upcoming request has failed.
  • added headers processing from native fetch() responses into simple objects
  • performance: optimized typings for api in createApiFetcher()
  • added types to output responses
  • parse withCredentials from axios when using native fetch()

Docs:

  • More detailed explanation of API and features
  • Added 1 more example with multiple API baseURLs
  • Added Vue integration example

Fixes:

  • When timeout passed is 0 then do not abort the requests

Breaking:

  • Deprecated RequestErrorHandler class - use onError interceptor (global or local per-request) directly instead

What's Changed

Full Changelog: v2.5.0...v2.6.0

v2.5.0

05 Aug 19:56
Compare
Choose a tag to compare

What's Changed

Features:

  • Allow to pass null to Query Params and URL Path Params
  • Accept per-request "baseURL", and do not use it, if url is provided directly
  • Performance: Don't run URL Path Replacement if it isn't necessary
  • Added possibility to use generics for responses in api.request and fetchf()
  • Performance: Bail early from appending Query Params if there are none to add
  • Handle other content types than application/json
  • Return request config and headers in the responses

Docs:

  • Added 2 more examples with api.request() and fetchf() usage in the examples.ts

Fixes:

  • Timeout error message url was not visible

Breaking:

  • flattenResponse setting is false by default
    To bring previous behavior either set it to "true" explicitly or start using destructuring for responses, e.g. change:
    const data = fetchf(...) to const { data } = fetchf(...)

Why "flattenResponse" is being changed to false?
Thanks to destructuring we can fit in more into the responses returned, so there is an easy access to errors, statuses etc. It helps when operating on the data. We also align it more with both axios and native fetch(). We will be able to add another properties like isLoading or isError in the near feature.

Full Changelog: v2.4.1...v2.5.0

v2.4.1

01 Aug 00:59
Compare
Choose a tag to compare

What's Changed

Fixes:

  • Improved typings inference with generics, e.g. const data = api.getMovies<Movies>() should not output error

v2.4.0

31 Jul 23:24
Compare
Choose a tag to compare

Features:

  • added onRequest and onResponse interceptors (with await in callbacks)

Fixes:

  • minor: request status should be visible in the message when request fails

Documentation:

  • added full example with all settings
  • minor improvements

Others:

  • added more test cases for interceptors (including onError) and cancellation

Full Changelog: v2.3.1...v2.4.0

v2.3.1

29 Jul 20:25
Compare
Choose a tag to compare

What's Changed

Fixes:

  • properly consider per-request retry configs
  • the retry callback "shouldRetry" is asynchronous now
  • passed fetcher does not explicitly require Axios only
  • Removed Axios types dependency
  • full response from fetch() might be received, if "flattenResponse" setting is set to false

Docs:

  • renamed urlParams to urlPathParams for clarity
  • added information about RequestConfig to Settings section
  • describe "urlPathParams" in settings.

Potentially breaking:

  • renamed APIUrlParams to UrlPathParams

Full Changelog: v2.3.0...v2.3.1

v2.3.0

29 Jul 14:57
Compare
Choose a tag to compare

What's Changed

Features:

  • added retry mechanism
  • added global "rejectCancelled" setting
  • added global request "method" setting (default is GET)
  • added per-request "flattenResponse" setting
  • added per-request "defaultResponse" setting
  • added tiny fetch compatible fetchf(url, config) wrapper to directly make requests without initializing API Handler (useful for single calls)
  • api.config - exposed global config that can be easily adjusted dynamically
  • api.endpoints - exposed list of endpoints so they can be adjusted dynamically
  • added support for uppercase dynamic URI params
  • added uriParams setting to requestConfig (useful in the fetchf() wrapper)
  • performance: smaller bundle size due to lack of external plugins

Typings:

  • added automatic endpoints types inference even if types have not been specified

Fixes:

  • always trigger console error for non-specified endpoints, instead of custom logger

Docs:

  • more clear explanation of package and settings
  • global and per request settings are now merged as they are pretty much same
  • added more examples of per-request error handling with each and every strategy
  • added docs/examples/examples.ts file with more examples of usage

Breaking:

  • ApiHandler class converted to createApiFetcher (please replace all new ApiHandler with createApiFetcher). This helps us to remove last external dependency making the library dependency-free
  • RequestErrorHandler class is not re-exported now. It should not be used directly in code
  • Removed long deprecated throwError strategy so to reduce bundle size. Use reject instead. The behavior is the same
  • Renamed type: EndpointConfig to RequestConfig
  • Renamed "handleRequest" method to "request"
  • More strict TypeScript when generic for createApiFetcher() is defined by default. All endpoints need to be specified.

Full Changelog: v2.2.2...v2.3.0

v2.2.2

26 Jul 00:50
Compare
Choose a tag to compare

Full Changelog: v2.2.1...v2.2.2

Fixes:

  • minor fixes to fetch() integration (baseURL & response handling)