v3.0.0
Features:
- Typings: Added Query Params, Path Params and Request Body generics to endpoints API, request() and fetchf() functions
Improvements:
- Added sideEffects false for more aggressive minification in bundlers
- Pointed default entry point to unpkg as ESM
- Size monitoring for Node.js build output when building
- Typings: Custom fetcher options typings - should infer Response Data
- Typings: Polling error object typings - should infer Response Data
- Typings: Infer response data in request config when using createApiFetcher()
- Typings: Updated ApiHandlerMethods -> ApiHandlerDefaultMethods and ApiHandlerReturnType -> ApiHandlerMethods
- Performance: Don't remove withCredentials and data properties from final fetch object
Fixes:
- Typings: Set default response type to
any
instead ofnever
- Typings: Response Data when error is returned
- Typings: Query Params, Url Path Params and Body Payload can infer whole generic interfaces instead of only values
- Typings: Properly infer TS generics in Endpoint type
- api.request() was not accepting custom URLs
Docs:
- Added more information about Compatibility and Polyfills
- Added section about Headers together with default headers being injected
- Added section about Response Data Transformation
- Added section about Automatic Request Cancellation
- "Multiple API Specific Settings" info regarding general settings moved to the Basic Settings section
- Updated JSDoc of API Handler interfaces
- Update generic Typings sections
- Add Plugin API Architecture section
Breaking changes:
- Simplified endpoints API in createApiFetcher() - removed
queryParamsOrBody
andurlPathParams
arguments from request() function. Use requestConfigparams
orbody
instead. - If
flattenResponse
is set to true, only thedata
is affected by flattening. It means that the whole response is always returned which increases predictability. If you setflattenResponse
anywhere, in order to migrate replace allconst data =
withconst { data } =
- Locked down build to minimum version of Node.js 18+ as per docs (smaller bundle)
- Builds should be in ES2018+ mode (smaller bundle; use transpiler if you need older versions)
What's Changed
Full Changelog: v2.9.0...v3.0.0