I have a function that takes a parameter and a callback. It\'s supposed to do a request to a remote API and get some info based on the parameter. When it gets the info, it needs
A library called Flashheart is also a suitable alternative. It's a rest client designed to be easy to use and supports retries.
For example, configure Flashheart to retry 10 times, with a delay of 500ms between requests:
const client = require('flashheart').createClient({
retries: 10,
retryTimeout: 500
});
const url = "https://www.example.com/";
client.get(url, (err, body) => {
if (err) {
console.error('handle error: ', err);
return;
}
console.log(body);
});
For further information, check out the docs: https://github.com/bbc/flashheart
Disclaimer: I have contributed to this library.