UNPKG

@mui/x-telemetry

Version:
24 lines (23 loc) 595 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchWithRetry = fetchWithRetry; async function fetchWithRetry(url, options, retries = 3) { try { const response = await fetch(url, options); if (response.ok) { return response; } throw new Error(`Request failed with status ${response.status}`); } catch (error) { if (retries === 0) { throw error; } return new Promise(resolve => { setTimeout(() => { resolve(fetchWithRetry(url, options, retries - 1)); }, Math.random() * 3_000); }); } }