@mui/x-telemetry
Version:
MUI X Telemetry.
24 lines (23 loc) • 684 B
JavaScript
;
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 /* FIXME (minify-errors-in-prod): Unminified error message in production build! */new Error(`MUI X: 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);
});
}
}