0.1.2 • Published 11 months ago
lightweight-use-fetch v0.1.2
Simple lightweight library for fetching data
The library exposes one hook and one helper method
- useFetch
- accepts two positional params:
- key {String} - the key for the data to be cached
useFetchOpts - object with the follow props: endpoint: string; headers?: HeadersInit; method: "GET" | "POST";
and returns object with:
- snapshot,
- isLoading,
- data,
- error,
- fetcher
The fetcher accepts object with:
- revalidate?: boolean;
- optimistic?: boolean;
- rollbackOnError?: boolean;
- body?: Record<string, any>;
executeInSequence(type: "sequntial" | "simultaneous" | "race", ...fns: Array<() => Promise):
- one of the following types - "sequntial" | "simultaneous" | "race"
- function that return Promises