Skip to content

Wraps some stuff around axios for async/await with retry and delay

Notifications You must be signed in to change notification settings

findmory/axios-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Install the library

npm install findmory/async-axios

Import it into your app

import axiosPlus from 'async-axios`

Setup Config object

let config = {

  /* url is mandatory */
  url: <string>,

  /* if no method, default is 'get' */
  method: <'get', 'post', etc>,

  /* data body for 'post', 'put', etc */
  data: {},

  /* timeout in milleseconds */
  timeout: <number>,

  /* retry delay in milleseconds */
  retryDelay: <number>,

  /* retry type.  one of;
    'static' (retryDelay = retryDelay)
    'linear' (retryDelay = # retries * retryDelay)
    'exponential (retryDelay = ((Math.pow(2, config.currentRetryAttempt) - 1) / 2) * 1000;)'
  */
  retryType: <string>,

  /* number of times to retry (-1: forever, 0: none)
  */
  retries: <integer>,

  /* callback to run during retry */
  retryCallback: <function>,

  /* Explicit Success Codes. List of resp codes to consider success */
  successCodes: <array>

}

Make the request

let resp = axiosPlus(config); // returns resp or `false`

About

Wraps some stuff around axios for async/await with retry and delay

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published