# @jhenbertnpm/use-fetch

> Custom hooks in Typescript to fetch data from API or database using any method returning a promise.

Latest version **2.0.6** (published 2024-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jhenbertnpm/use-fetch
pnpm add @jhenbertnpm/use-fetch
yarn add @jhenbertnpm/use-fetch
bun add @jhenbertnpm/use-fetch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2024-02-17 |
| First published | 2023-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jhenbert |
| Maintainers | jhenbertnpm |
| Keywords | useFetch, promise, api, custom, hooks |

## Links

- npm: https://www.npmjs.com/package/@jhenbertnpm/use-fetch
- npm.io page: https://npm.io/package/@jhenbertnpm/use-fetch

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.0.6 (latest) — 2024-02-17
- 2.0.5 — 2023-11-27
- 2.0.4 — 2023-11-25
- 2.0.3 — 2023-11-25
- 2.0.2 — 2023-11-25
- 2.0.1 — 2023-11-21
- 2.0.0 — 2023-11-21

## README

# Quickstart

Using the custom hook

```bash

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](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). You can also use [Axios](https://axios-http.com/docs/intro) or any other [promise-based](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) http client.

---
_Source: https://npm.io/package/@jhenbertnpm/use-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
