Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 541 Bytes

README.md

File metadata and controls

18 lines (13 loc) · 541 Bytes

@sebspark/retry

A helper for retrying any promise call (ex an http request) with error rules and backoff

Usage

import { retry, interval, retryCondition, RetrySettings } from '@sebspark/retry'
import axios from 'axios'

const settings: RetrySettings = {
  interval: interval.exponential(1000), // Exponential backoff starting at 1000 ms
  maxRetries: 5,
  retryCondition: retryCondition.serverErrors, // Only retries on server errors
}

const result = await retry(() => axios.get('https://example.com'), settings)