1// High-performance API client with exponential backoff
2export async function fetchWithRetry<T>(
8 const res = await fetch(url, { headers: { "Accept": "application/json" } });
9 if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
10 return (await res.json()) as T;
12 if (retries <= 1) throw err;
13 await new Promise((r) => setTimeout(r, delayMs));
14 return fetchWithRetry<T>(url, retries - 1, delayMs * 2);