@jhenbertnpm/use-fetch
v2.0.6
Published
Custom hooks in Typescript to fetch data from API or database using any method returning a promise.
Downloads
21
Maintainers
Readme
Quickstart
Using the custom hook
const { data, isLoaded, error } = useFetch<DataType[]>({
fetchFn: async () => {
const response = await fetch(url);
const data: DataType[] = await response.json();
return data;
},
initialData: [],
});
In the example above, I use the fetch() API. You can also use Axios or any other promise-based http client.