Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Timeout pattern const timeout = ms => new Promise((_, r) => setTimeout(() => r(new Error("Timeout")), ms)); const result = await Promise.race([fetch("/api/data"), timeout(3000)]); // First successful CDN const img = await Promise.any([fetchFrom("cdn1"), fetchFrom("cdn2"), fetchFrom("cdn3")]);
Result
Open