MCPcopy Create free account
hub / github.com/FreeMovieIR/freemovieir.github.io / fetchWithTimeout

Function fetchWithTimeout

js/apiClient.js:22–36  ·  view source on GitHub ↗
(url, options = {})

Source from the content-addressed store, hash-verified

20 }
21
22 async function fetchWithTimeout(url, options = {}) {
23 const timeoutMs = options.timeoutMs || config.requestTimeoutMs || 12000;
24 const controller = new AbortController();
25 const timer = setTimeout(() => controller.abort(), timeoutMs);
26 const { timeoutMs: _timeoutMs, ...fetchOptions } = options;
27
28 try {
29 return await fetch(url, {
30 ...fetchOptions,
31 signal: fetchOptions.signal || controller.signal
32 });
33 } finally {
34 clearTimeout(timer);
35 }
36 }
37
38 async function request(url, options = {}) {
39 const retries = Number.isInteger(options.retries) ? options.retries : (config.requestRetries || 0);

Callers 1

requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected