Extra utilities for ruse-fetch.
These methods are similar to the ones from ruse-fetch
, but they add:
- Support for JSON bodies: set
body
to an object, and it will serialize it, and set the content-type - Support for GET params: set
params
to an object, and it will be converted to a query string and added to the url - Auto-add the user token from the store: just save it at
store.user.token
Similar to useFetchCb
, but does not dispatch anything. This is similar to calling plain fetch, but with all the additions above.
This hook helps deal with "infinite scroll" use cases. It works like useFetch
, but returns an object with the following fields:
-
data
: The aggregated results from the pages loaded so far -
page
: The last page loaded -
isLoadingMore
: Indicates if we are loading a new page -
hasNext
: Indicates if there are more pages to load -
loadMore
: Function to load the next page of results
The behaviour for concatenating pages and detecting the last page can be customised with the merger
and hasNext
options
Provides CRUD methods for an entity. It assumes the standard REST URLs for each method.
Similar to useFetch
, but updates the data automatically with the specified period.
Please note that this method does not de-duplicate calls with the same URL.