Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

20 строки
630 B

  1. export async function waitForHttp(url, options = {}) {
  2. const timeoutMs = options.timeoutMs || 60000;
  3. const intervalMs = options.intervalMs || 500;
  4. const start = Date.now();
  5. let lastError;
  6. while (Date.now() - start < timeoutMs) {
  7. try {
  8. const response = await fetch(url, { cache: 'no-store' });
  9. if (response.ok) return response;
  10. lastError = new Error(`HTTP ${response.status}`);
  11. } catch (error) {
  12. lastError = error;
  13. }
  14. await new Promise((resolve) => setTimeout(resolve, intervalMs));
  15. }
  16. throw new Error(`Timed out waiting for ${url}: ${lastError?.message || 'no response'}`);
  17. }