Releases: MattCCC/fetchff
v2.6.3
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
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:
Full Changelog: v2.6.1...v2.6.2
v2.6.1
v2.6.0
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
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(...)
toconst { 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
v2.4.0
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
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
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 dynamicallyapi.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
withcreateApiFetcher
). 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. Usereject
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
Full Changelog: v2.2.1...v2.2.2
Fixes:
- minor fixes to fetch() integration (baseURL & response handling)