exponential-backoff
Installation
npm i exponential-backoffUsage
function backOff<T>(
request: () => Promise<T>,
options?: BackOffOptions
): Promise<T>;import { backOff } from "exponential-backoff";
function getWeather() {
return fetch("weather-endpoint");
}
async function main() {
try {
const response = await backOff(() => getWeather());
// process response
} catch (e) {
// handle error
}
}
main();BackOffOptions
BackOffOptionsLast updated