Q:

Timed retry on axios failure

I am using axios in the node module that I am developing for private use. On network failure, I want to perform retries in certain intervals (like exponential backoff). I have done this in my other react-redux project using delay from redux-saga. Below is the snippet of it:
return dealy(500).then(() => axios(error.config))

I want to achieve the same thing using plain es6 or suggest me if there are any light-weight delay libraries.

A:

I do not want to use third-party library for this only purpose. I had created a custom delay method that returns promise and resolves after certain point of time. Here is the snippet for the same:
const delay = (timeMs) => new Promise((resolve) => setTimeout(() => resolve(), timeMs));

This solved my issue.

