MCPcopy Create free account
hub / github.com/AICoderTudou/claude-code-tudou / fetchJsonWithTimeout

Function fetchJsonWithTimeout

desktop/main.cjs:189–212  ·  view source on GitHub ↗
(url, { headers = {}, timeoutMs = 15000 } = {})

Source from the content-addressed store, hash-verified

187}
188
189async function fetchJsonWithTimeout(url, { headers = {}, timeoutMs = 15000 } = {}) {
190 const controller = new AbortController();
191 const timer = setTimeout(() => controller.abort(), timeoutMs);
192 try {
193 const response = await fetch(url, {
194 method: "GET",
195 headers,
196 signal: controller.signal,
197 });
198 const text = await response.text();
199 let data = null;
200 try {
201 data = JSON.parse(text);
202 } catch {}
203 return {
204 ok: response.ok,
205 status: response.status,
206 data,
207 text,
208 };
209 } finally {
210 clearTimeout(timer);
211 }
212}
213
214function normalizeModelEntries(list, provider) {
215 if (!Array.isArray(list)) return [];

Callers 2

listOpenRouterModelsFunction · 0.85
listAnthropicModelsFunction · 0.85

Calls 1

textMethod · 0.80

Tested by

no test coverage detected