@jhenbertnpm/use-fetch

2.0.6 • Public • Published

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.

Package Sidebar

Install

npm i @jhenbertnpm/use-fetch

Weekly Downloads

1

Version

2.0.6

License

MIT

Unpacked Size

1.83 kB

Total Files

3

Last publish

Collaborators

  • jhenbertnpm