Better fetch provides flexible retry mechanisms with both linear and exponential backoff strategies. You can customize the retry behavior to suit your specific needs.
constres = await$fetch("https://jsonplaceholder.typicode.com/todos/1", {retry: {type: "linear",attempts: 3,delay: 1000 // 1 second delay between each attempt }});
Exponential backoff strategy:
fetch.ts
constres = await$fetch("https://jsonplaceholder.typicode.com/todos/1", {retry: {count: 3,interval: 1000, //optionaltype: "exponential",attempts: 5,baseDelay: 1000, // Start with 1 second delaymaxDelay: 10000 // Cap the delay at 10 seconds, so requests would go out after 1s then 2s, 4s, 8s, 10s }});