# hooks-usefetch

> 为了更方便的发送处理数据请求所开发的hook钩子函数

Latest version **3.0.1** (published 2021-10-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install hooks-usefetch
pnpm add hooks-usefetch
yarn add hooks-usefetch
bun add hooks-usefetch
```

## 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 | 3.0.1 |
| Published | 2021-10-15 |
| First published | 2021-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | k_wang |
| Maintainers | k_wang |
| Keywords | hook, react, usefetch, axios, http, 钩子函数 |

## Links

- npm: https://www.npmjs.com/package/hooks-usefetch
- Repository: https://github.com/k-w-wang/usehooks
- Homepage: https://github.com/k-w-wang/usehooks#readme
- Issues: https://github.com/k-w-wang/usehooks/issues
- npm.io page: https://npm.io/package/hooks-usefetch

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^17.0.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [react-use](https://npm.io/package/react-use.md) ^17.2.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2021-10-15
- 3.0.0 — 2021-10-14
- 2.0.0 — 2021-10-14
- 1.0.0 — 2021-10-12

## README

简介：基础react-hook开发的钩子函数

npm i ts-usehooks
# useFetch

1、钩子函数useFetch

为了配合hooks进行发送数据请求
能够在自己组件直接获取到后台数据
解决每个函数都要统一写try/catch的流程
解决发送请求需要手动加锁防止多次重复请求的痛点
不需要在手动useState loading，直接获取loading值

使用方法

import { useFetch } from "ts-usehooks"

list: 后台返回的数据

getNewList: 重新发起请求方法，需要两个参数（当请求和上一次请求发送的参数一样时不会重新请求）
params：发送给后台的参数 focus？：强制发送一次请求（布尔值）

Refresh: 刷新请求，重新获取一遍数据

getLists: 接口api，

{}: 第一次请求的参数

const [list, getNewList, Refresh ] = useFetch(getLists, {})

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