MCPcopy Create free account
hub / github.com/developersdigest/llm-answer-engine / fetchWithTimeout

Function fetchWithTimeout

app/tools/contentProcessing.tsx:33–46  ·  view source on GitHub ↗
(url: string, options: RequestInit = {}, timeout = 800)

Source from the content-addressed store, hash-verified

31// Fetch contents of top 10 search results
32export async function get10BlueLinksContents(sources: SearchResult[]): Promise<ContentResult[]> {
33 async function fetchWithTimeout(url: string, options: RequestInit = {}, timeout = 800): Promise<Response> {
34 try {
35 const controller = new AbortController();
36 const timeoutId = setTimeout(() => controller.abort(), timeout);
37 const response = await fetch(url, { ...options, signal: controller.signal });
38 clearTimeout(timeoutId);
39 return response;
40 } catch (error) {
41 if (error) {
42 console.log(`Skipping ${url}!`);
43 }
44 throw error;
45 }
46 }
47 function extractMainContent(html: string): string {
48 try {
49 const $ = cheerio.load(html);

Callers 1

get10BlueLinksContentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected