@huudan/retry-promise-util
TypeScript icon, indicating that this package has built-in type declarations

0.7.0 • Public • Published

@huudan/retry-promise-util

Retries a function returning a promise with a delay between each retry

Usage

import { retryPromise } from '@huudan/retry-promise-util';

retryPromise(() => fetch('https://api.example.com'), {
  delay: 2000, // Milliseconds between each retry
  multiplier: 2, // Multiplier for delay (ex: 2000, 4000, 8000...)
  retries: 3 // Number of retries after the promise is rejected
}).then((response) => response.json())
  .then(console.log)
  .catch(console.error);

Readme

Keywords

Package Sidebar

Install

npm i @huudan/retry-promise-util

Weekly Downloads

5

Version

0.7.0

License

MIT

Unpacked Size

9.43 kB

Total Files

7

Last publish

Collaborators

  • nghuudan