# retryable-request

> Small lib helps sending retryable requests on top of axios

Latest version **1.0.11** (published 2021-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install retryable-request
pnpm add retryable-request
yarn add retryable-request
bun add retryable-request
```

## 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 | 1.0.11 |
| Published | 2021-02-12 |
| First published | 2021-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | Abdallah Zidan |
| Maintainers | abdallah-zidan |

## Links

- npm: https://www.npmjs.com/package/retryable-request
- npm.io page: https://npm.io/package/retryable-request

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.21.1
- [retry](https://npm.io/package/retry.md) ^0.12.0

## Recent versions

- 1.0.11 (latest) — 2021-02-12
- 1.0.10 — 2021-02-10
- 1.0.9 — 2021-02-10
- 1.0.8 — 2021-02-10
- 1.0.7 — 2021-02-10
- 1.0.6 — 2021-02-09
- 1.0.5 — 2021-02-09
- 1.0.4 — 2021-02-08
- 1.0.3 — 2021-02-06
- 1.0.2 — 2021-02-06
- 1.0.1 — 2021-02-06
- 1.0.0 — 2021-02-06

## README

# retryable-request

Sending retryable requests easily 

## Table of Contents

    - [Features](#features)
    - [Installing](#installing)
    - [Example](#example)
    - [Credits](#credits)
    - [License](#license)

## Features

    - Send normal request using sendRequest function
    - Creating retryable request using createRetryableRequest function
    - Send retryable request using sendRetryable request function
    - Alternatively you can perform the previous functionality using RetryableRequest class instead.
    - Everything is promise based and compaitable with axios http client

## Installing
    
Using npm:

```bash
$ npm install retryable-request
```

Using yarn:

```bash
$ yarn add retryable-request
```

## Example


```js
const { createRetryableRequest } = require("retryable-request");

const request = createRetryableRequest({
  requestOptions: {
    url: "https://jsonplaceholder.typicode.com/todos",
  },
  retryOptions: {
    retries: 3,
  },
  retryCB: (e, currentAttempt) =>
    console.log(`${e.message} - currentAttempt: ${currentAttempt}`),
});

request()
  .then((data) => console.log(data.data))
  .catch((e) => console.log(e.message));

```

```js
// using RetryableRequest class which supports axios interceptors and have default ones
  
  const {RetryableRequest}  =  require("retryable-request");
  const client = RetryableRequest.instance({ defaultInterceptors: true });
  // normal request
  client.sendRequest({
      url:"https://jsonplaceholder.typicode.com/todos",
  }).then(console.log).catch(console.log);

  // retryable request
  client.sendRetryableRequest({
      requestOptions: {
        url: "https://jsonplaceholder.typicode.com/todos",
      },
      retryOptions: {
        retries: 3,
      },
      retryCB: (e, currentAttempt) =>
        console.log(e,currentAttempt),
  }).then(console.log).catch(console.log);

```

## Credits

    - Abd Allah Zidan

## License
    - MIT

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