# http-retries

> 为 Fetch 增加重试功能

Latest version **0.1.0** (published 2022-07-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install http-retries
pnpm add http-retries
yarn add http-retries
bun add http-retries
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-07-15 |
| First published | 2022-07-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kenny6520 |

## Links

- npm: https://www.npmjs.com/package/http-retries
- npm.io page: https://npm.io/package/http-retries

## Recent versions

- 0.1.0 (latest) — 2022-07-15
- 0.0.3 — 2022-07-11
- 0.0.2 — 2022-07-11
- 0.0.1 — 2022-07-11

## README

# retry

为 Fetch 增加重试功能

```typescript
import { enhanceFetchRetry as createFetchRetry } from "../../lib/fecth";

const successURL = "https://jsonplaceholder.typicode.com/todos/1";
const errorURL = successURL + "error";

const myFetch = createFetchRetry(fetch, {
  retries: 5,
  delay: 1000,
  condition: function (
    promiseResponse,
    response,
    count,
    context,
    retryOptions
  ) {
    console.log(count);
    if (count >= 2) {
      context.input = successURL;
    }
    return response.status === 404;
  },
});

myFetch(errorURL)
  .then((res) => {
    console.log("Success", res);
  })
  .catch((...errors) => {
    console.log(errors);
  });
```

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