Implement fetchWithRetry(fetch, url, { retries, backoffMs })
Write fetchWithRetry(fetch, url, { retries = 3, backoffMs = 10 }) that retries a request when the response status is 5xx, waiting backoffMs between attempts, up to retries additional attempts beyond the first. Returns the parsed JSON body on the first success. If every attempt fails, throw an error describing how many attempts were made.
// A flaky endpoint that fails twice, then succeeds, resolves with the JSON body,
// having made exactly 3 requests total.
await fetchWithRetry(fetch, "/flaky", { retries: 3, backoffMs: 10 });