Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bart_info.art.src%7D?q=fetch&page=86&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 8585 results for "fetch"(594ms)

HTTP101guides1 match

@willthereader•Updated 1 week ago
40app.get("/guides/HTTP101", HTTP101);
41
42export default app.fetch;

guidemain.tsx1 match

@salon•Updated 1 week ago
122 return generatedData;
123 } catch (error) {
124 console.error("Error fetching or processing data from OpenAI:", error);
125 console.warn("Using fallback race data due to the error.");
126 // Ensure fallback data also has the hint, slice correctly

policy2main.tsx9 matches

@salon•Updated 1 week ago
592 errorInvalidFile: "Invalid file type. Please upload a PDF.",
593 errorFileSize: "File is too large (Max {maxSize}).",
594 errorFetchFailed: "Failed to perform analysis: {errorMessage}",
595 // Contact Placeholders
596 contactNamePlaceholder: "Your Name",
651 errorInvalidFile: "Tipo de archivo inválido. Por favor, suba un PDF.",
652 errorFileSize: "El archivo es demasiado grande (Máx {maxSize}).",
653 errorFetchFailed: "Falló la realización del análisis: {errorMessage}",
654 // Contact Placeholders
655 contactNamePlaceholder: "Tu Nombre",
851
852 try {
853 const response = await fetch(window.location.pathname + '?format=json', { method: 'POST', headers: { 'Accept': 'application/json'}, body: formData });
854 updateLoadingProgress(25, 'loadingStatusAnalysis'); // Adjusted percentage
855 const data = await response.json();
884 } catch (error) {
885 console.error('Analysis Request Error:', error);
886 displayError('errorFetchFailed', { errorMessage: error.message });
887 resultsContent.style.display = 'none'; // Ensure results area hidden on error
888 noResultsMessage.style.display = 'block';
918 const { OpenAI } = await import("https://esm.town/v/std/openai");
919 const { z } = await import("npm:zod");
920 const { fetch } = await import("https://esm.town/v/std/fetch");
921 const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract");
922
1001 try {
1002 log.push({ agent, type: "step", message: `Workspaceing: ${url}` });
1003 const res = await fetch(url, {
1004 headers: { "User-Agent": "ValTownPolicyAnalysisBot/1.0" },
1005 redirect: "follow",
1074 try {
1075 if (!input.documentUrl.match(/^https?:\/\//i)) throw new Error("Invalid URL scheme.");
1076 const res = await fetch(input.documentUrl, {
1077 headers: { "Accept": "text/plain, text/html, application/pdf", "User-Agent": "ValTownPolicyAnalysisBot/1.0" },
1078 redirect: "follow",
1091 } else if (ct.includes("text/") || ct === "") {
1092 const text = await res.text();
1093 if (!text?.trim()) throw new Error("Fetched empty text.");
1094 log.push({ agent: ingestAgent, type: "result", message: `Workspaceed ~${text.length} chars.` });
1095 docText = text;
1096 } else { throw new Error(`Unsupported content type: ${ct}`); }
1097 } catch (e) {
1098 log.push({ agent: ingestAgent, type: "error", message: `URL fetch/process failed: ${e.message}` });
1099 docText = null;
1100 }

whatDoYouThinkOfItSoFarmain.tsx2 matches

@edgeeffect•Updated 1 week ago
1import { email } from "https://esm.town/v/std/email";
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
3import { type Document, DOMParser, type Node } from "jsr:@b-fuze/deno-dom";
4
42
43export default (interval: Interval) => {
44 fetchText(
45 Deno.env.get("rubbish_url")
46 ).then(html => {

Pathwaymain.tsx15 matches

@Get•Updated 1 week ago
84interface TraversedCitation extends Citation {
85 traversalStatus: "success" | "not_attempted" | "failed" | "url_missing";
86 fetchedContentSummary?: string;
87 error?: string;
88}
291
292 try {
293 const response = await fetch(window.location.pathname + '?format=json', {
294 method: 'POST',
295 headers: { 'Accept': 'application/json' },
341 const { OpenAI } = await import("https://esm.town/v/std/openai");
342 const { z } = await import("npm:zod");
343 const { fetch } = await import("https://esm.town/v/std/fetch");
344 // Import the PDF extraction library
345 const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract");
441 for (const citation of citations) {
442 // Basic URL validation and prepending https:// if missing protocol
443 let urlToFetch = citation.potentialUrl;
444 if (urlToFetch) {
445 try {
446 // Attempt to construct a URL to validate/normalize it
447 const parsedUrl = new URL(urlToFetch.startsWith("http") ? urlToFetch : `https://${urlToFetch}`);
448 urlToFetch = parsedUrl.href; // Use the normalized URL
449 } catch (_) {
450 log.push({ agent, type: "error", message: `Invalid potential URL format: ${citation.potentialUrl}` });
457 let errorMsg: string | undefined = undefined;
458 try {
459 log.push({ agent, type: "step", message: `Workspaceing reference: ${urlToFetch}` });
460 const response = await fetch(urlToFetch, {
461 headers: { "User-Agent": "ValTownPolicyAnalysisBot/1.0" },
462 redirect: "follow",
465 if (!response.ok) throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);
466 status = "success";
467 log.push({ agent, type: "result", message: `Successfully accessed: ${urlToFetch}` });
468 } catch (error) {
469 errorMsg = `Failed to fetch reference ${urlToFetch}: ${error.message}`;
470 log.push({ agent, type: "error", message: errorMsg });
471 status = "failed";
472 }
473 results.push({ ...citation, potentialUrl: urlToFetch, traversalStatus: status, error: errorMsg }); // Store normalized URL
474 } else { results.push({ ...citation, traversalStatus: "url_missing" }); }
475 }
524 log.push({ agent: ingestionAgent, type: "step", message: `Workspaceing from URL: ${input.documentUrl}` });
525 try {
526 const response = await fetch(input.documentUrl, { headers: { "Accept": "text/plain, text/html" } });
527 if (!response.ok) throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);
528 const text = await response.text();
529 if (!text || text.trim().length === 0) throw new Error("Fetched content is empty or not text.");
530 log.push({
531 agent: ingestionAgent,
535 documentText = text;
536 } catch (error) {
537 const errorMessage = `Failed to fetch or process URL ${input.documentUrl}: ${error.message}`;
538 log.push({ agent: ingestionAgent, type: "error", message: errorMessage });
539 documentText = null;

Test2main.tsx5 matches

@Get•Updated 1 week ago
6
7import { OpenAI } from "https://esm.town/v/std/openai";
8// import { Request, Response } from "https://esm.town/v/std/fetch"; // Usually global
9
10// --- Define Expected Data Structures ---
50// --- ***** THIS FUNCTION WAS MISSING ***** ---
51// --- OpenAI Generation Function ---
52// Asynchronously fetches race data from OpenAI's Chat Completion API.
53async function generateRaceDataWithOpenAI(): Promise<RaceInfo[]> {
54 let openai;
136 }));
137 } catch (error) {
138 console.error("Error fetching or processing data from OpenAI:", error);
139 if (error.constructor.name === "AuthenticationError") {
140 console.error("OpenAI Authentication Error: Check 'openai' secret.");
152 console.log("Server function started."); // Log start
153
154 // 1. Fetch Race Data - Ensure this line is calling the function defined above
155 console.log("Attempting to fetch race data...");
156 const activeRaceData = await generateRaceDataWithOpenAI();
157 console.log(`Workspaceed ${activeRaceData.length} races. First race: ${activeRaceData[0]?.name || "N/A"}`);

usmnt_world_cup_roster_trackermanifold-api.ts15 matches

@dcm31•Updated 1 week ago
1// Service for fetching data from Manifold API
2interface Answer {
3 id: string;
265
266/**
267 * Fetches comments for a specific market from Manifold API
268 */
269async function fetchMarketComments(marketId: string): Promise<Comment[]> {
270 try {
271 console.log(`Fetching comments for market ${marketId}`);
272 const url = `https://api.manifold.markets/v0/comments?contractId=${marketId}&limit=1000`;
273 console.log(`Fetching from URL: ${url}`);
274
275 const response = await fetch(url);
276
277 if (!response.ok) {
305 return [];
306 } catch (error) {
307 console.error("Error fetching comments:", error);
308 return [];
309 }
311
312/**
313 * Fetches player data from Manifold API and categorizes them
314 */
315export async function fetchPlayerData(): Promise<PlayerData | null> {
316 try {
317 // Fetch market data from Manifold API
318 const marketResponse = await fetch(`https://api.manifold.markets/v0/market/${MARKET_ID}`);
319
320 if (!marketResponse.ok) {
328 }
329
330 // Separately fetch comments
331 const comments = await fetchMarketComments(MARKET_ID);
332 console.log(`Fetched ${comments.length} comments`);
333
334 // Extract player positions from comments if available
426 };
427 } catch (error) {
428 console.error("Error fetching player data:", error);
429 return null;
430 }

parkingSpotsmain.tsx2 matches

@paulsun•Updated 1 week ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export function parkingSpots(lat, lng, radius = 5) {
4 return fetch(
5 `https://park4night.com/api/places/around?lat=${lat}&lng=${lng}&radius=${radius}&filter=%7B%7D&lang=en`,
6 ).then((res) => res.json());

MiniAppStarterneynar.ts14 matches

@applefather•Updated 1 week ago
1const baseUrl = "https://api.neynar.com/v2/farcaster/";
2
3export async function fetchNeynarGet(path: string) {
4 const res = await fetch(baseUrl + path, {
5 method: "GET",
6 headers: {
14}
15
16export function fetchUser(username: string) {
17 return fetchNeynarGet(`user/by_username?username=${username}`).then(r => r.user);
18}
19export function fetchUsersById(fids: string) {
20 return fetchNeynarGet(`user/bulk?fids=${fids}`).then(r => r.users);
21}
22
23export function fetchUserFeed(fid: number) {
24 return fetchNeynarGet(
25 `feed?feed_type=filter&filter_type=fids&fids=${fid}&with_recasts=false&with_replies=false&limit=100&cursor=`,
26 ).then(r => r.casts);
27}
28
29export function fetchChannel(channelId: string) {
30 return fetchNeynarGet(`channel?id=${channelId}`).then(r => r.channel);
31}
32
33export function fetchChannelFeed(channelId: string) {
34 return fetchNeynarGet(
35 `feed/channels?channel_ids=${channelId}&with_recasts=false&limit=100`,
36 ).then(r => r.casts);
37}
38
39export function fetchChannelsFeed(channelIds: array) {
40 return fetchNeynarGet(
41 `feed/channels?channel_ids=${channelIds.join(",")}&with_recasts=false&limit=100`,
42 ).then(r => r.casts);

MiniAppStarterindex.tsx2 matches

@applefather•Updated 1 week ago
63});
64
65// HTTP vals expect an exported "fetch handler"
66// This is how you "run the server" in Val Town with Hono
67export default app.fetch;

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago