A tiny utility for exponentially retrying
This is free to use software, but if you do like it, consider supporting me ❤️
import { retry } from 'rtri';
const get_data = await retry(
async () => {
const response = await fetch('https://example.com');
if (!response.ok) throw new Error('not ok');
return response.json();
},
{ attempts: 3 },
);
await get_data();
MIT © Marais Rossouw