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=38&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 8163 results for "fetch"(1401ms)

discord-botApp.tsx4 matches

@boucher•Updated 4 days ago
21 const [error, setError] = useState<string | null>(null);
22
23 // Fetch server health status on component mount
24 useEffect(() => {
25 async function checkHealth() {
26 try {
27 setStatus('loading');
28 const response = await fetch('/health');
29 if (!response.ok) {
30 throw new Error(`Health check failed: ${response.status}`);
116 </tr>
117 <tr>
118 <td className="px-6 py-4 whitespace-nowrap font-mono text-sm">/api/fetch-dms</td>
119 <td className="px-6 py-4 whitespace-nowrap text-sm">POST</td>
120 <td className="px-6 py-4 text-sm">Manually trigger DM fetching</td>
121 </tr>
122 <tr>

discord-botDISCORD_BOT_SETUP.md3 matches

@boucher•Updated 4 days ago
112 - Find your deployed functions
113 - Add the same environment variables from your `.env` file
1145. Set up a scheduled task for periodic DM fetching:
115 - Create a new scheduled task in Val.town
116 - Use the `discordDMBotCron` function
129 - `/analyze Summarize our furniture discussions`
130
1313. You can also manually trigger a DM fetch:
132 ```
133 node val-town-cron.js
141- Verify that the bot has proper permissions
142
143### Cannot fetch DMs
144- Ensure both you and your spouse have DMed each other at least once
145- Verify that all tokens and IDs in the `.env` file are correct

vt-discordindex.ts2 matches

@boucher•Updated 4 days ago
21});
22
23// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;

MLSpointsPerMillionmain.tsx30 matches

@dcm31•Updated 4 days ago
375}
376
377async function fetchClubProfileFromApi(
378 transfermarktId: string | null | undefined,
379): Promise<ClubProfile | null> {
382 }
383 try {
384 const response = await fetch(`/api/clubProfile/${transfermarktId}`);
385 if (!response.ok) {
386 console.error(
387 `Failed to fetch profile from API for ${transfermarktId}: ${response.status}`,
388 );
389 return null;
401 } catch (error) {
402 console.error(
403 `Error fetching profile from API for ${transfermarktId}:`,
404 error,
405 );
635 setIsLoading(true);
636 setErrorMessage(null);
637 fetch("/api/standings")
638 .then((response) => response.json())
639 .then((data: Standings) => {
648 } else {
649 console.error(
650 "Fetched standings data is not in the expected format:",
651 data,
652 );
653 setStandings([]);
654 setLastUpdated("Error fetching base standings");
655 setErrorMessage(
656 "Failed to load standings data. Invalid format received.",
660 if (data.error) {
661 console.warn(
662 "Server reported an error fetching standings:",
663 data.error,
664 );
667 })
668 .catch((error) => {
669 console.error("Error fetching base standings:", error);
670 setLastUpdated("Error fetching base standings");
671 setErrorMessage(
672 `Failed to load standings data: ${(error as Error).message}`,
681 setIsLoading(true);
682
683 const fetchAllProfiles = async () => {
684 const allEntries = standings.flatMap((conf) => conf.entries);
685 const uniqueTmIds = [
695 setClubValues((prev) => ({ ...prev, ...initialValues }));
696
697 const profilePromises = uniqueTmIds.map((tmId) => fetchClubProfileFromApi(tmId));
698 const results = await Promise.allSettled(profilePromises);
699
707 if (result.status === "rejected") {
708 console.error(
709 `Failed to fetch profile for ID ${tmId}:`,
710 result.reason,
711 );
719 };
720
721 fetchAllProfiles();
722 }, [standings]);
723
876}
877
878async function fetchAndCacheClubProfile_SERVER(
879 transfermarktId: string,
880): Promise<ClubProfile | null> {
904 const options = { method: "GET", headers: { accept: "application/json" } };
905 try {
906 const response = await fetch(url, options);
907 let result: ClubProfile | null = null;
908 let errorMsg: string | null = null;
915 }
916 } else {
917 errorMsg = `Club profile fetch failed for ${transfermarktId}: ${response.status} ${await response.text().catch(
918 () => ""
919 )}`;
936 } catch (error) {
937 console.error(
938 `Error during fetch/process profile for ${transfermarktId}:`,
939 error,
940 );
944}
945
946async function fetchMLSStandings(): Promise<Standings> {
947 const KEY = "MLSpointsPerMillion_mls_standings_v2";
948 let storedData: Standings | null = null;
962 || now - storedData.timestamp > STANDINGS_CACHE_DURATION
963 ) {
964 console.log("Fetching fresh MLS standings data...");
965 const url = "https://major-league-soccer-standings.p.rapidapi.com/";
966 const apiKey = Deno.env.get("RAPIDAPI_KEY")
980 };
981 try {
982 const response = await fetch(url, options);
983 if (!response.ok) {
984 throw new Error(
996 storedData = { timestamp: now, standings: result };
997 await blob.setJSON(KEY, storedData);
998 console.log("Successfully fetched and cached new standings data.");
999 return storedData;
1000 } catch (error) {
1001 console.error("Error fetching or processing MLS standings:", error);
1002 if (storedData) {
1003 console.warn("Returning stale standings data due to fetch error.");
1004 return {
1005 ...storedData,
1006 error: `Failed to fetch fresh standings: ${(error as Error).message}. Displaying cached data.`,
1007 };
1008 } else {
1010 timestamp: now,
1011 standings: [],
1012 error: `Failed to fetch MLS standings: ${(error as Error).message}`,
1013 };
1014 }
1030 // API endpoint for standings data
1031 if (url.pathname === "/api/standings") {
1032 const standingsData = await fetchMLSStandings();
1033 return new Response(JSON.stringify(standingsData), {
1034 headers: headers_json,
1047 });
1048 try {
1049 const profileData = await fetchAndCacheClubProfile_SERVER(transfermarktId);
1050 if (profileData)
1051 return new Response(JSON.stringify(profileData), {
1054 }); else
1055 return new Response(
1056 JSON.stringify({ error: "Profile not found or fetch failed" }),
1057 { headers: headers_json, status: 404 },
1058 );
1059 } catch (error) {
1060 console.error(`Server error fetching profile ${transfermarktId}:`, error);
1061 return new Response(
1062 JSON.stringify({

Projectmain.tsx22 matches

@Get•Updated 4 days ago
85interface TraversedCitation extends Citation {
86 traversalStatus: "success" | "not_attempted" | "failed" | "url_missing";
87 fetchedContentSummary?: string; // Note: Original code didn't fetch summary, only status
88 error?: string;
89}
479 errorInvalidFile: "Invalid file type. Please upload a PDF.",
480 errorFileSize: "File is too large (Max {maxSize}).", // Updated to use replacement
481 errorFetchFailed: "Failed to perform analysis: {errorMessage}", // Placeholder for dynamic message
482 analysisTitle: "Analysis Results", // Keep if needed elsewhere, dashboard cards have own titles now
483 loadingAnalysis: "Analyzing Document...",
515 errorInvalidFile: "Tipo de archivo inválido. Por favor, suba un PDF.",
516 errorFileSize: "El archivo es demasiado grande (Máx {maxSize}).", // Updated
517 errorFetchFailed: "Falló la realización del análisis: {errorMessage}",
518 analysisTitle: "Resultados del Análisis",
519 loadingAnalysis: "Analizando Documento...",
819
820 try {
821 // Fetch from the current location, expecting the Val to handle POST
822 const response = await fetch(window.location.pathname + '?format=json', { // Ensure format=json is requested
823 method: 'POST',
824 headers: { 'Accept': 'application/json'}, // Crucial: Tell server we want JSON back
909 console.error('Analysis Request Error:', error);
910 // Use the specific error message from the caught error
911 displayError('errorFetchFailed', { errorMessage: error.message });
912 resultsArea.style.display = 'none';
913 } finally {
952 const { OpenAI } = await import("https://esm.town/v/std/openai");
953 const { z } = await import("npm:zod");
954 const { fetch } = await import("https://esm.town/v/std/fetch");
955 // Import the PDF extraction library
956 const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract");
1040 const traversalPromises = citations.map(async (citation): Promise<TraversedCitation> => {
1041 if (citation.potentialUrl) {
1042 traversedCount++; // Increment here is slightly inaccurate if fetch fails early, but simpler
1043 let status: TraversedCitation["traversalStatus"] = "failed";
1044 let errorMsg: string | undefined = undefined;
1045 let urlToFetch = citation.potentialUrl;
1046 // Basic URL validation/fixing
1047 if (!urlToFetch.startsWith('http://') && !urlToFetch.startsWith('https://')) {
1048 urlToFetch = 'http://' + urlToFetch; // Default to http if protocol missing
1049 }
1050
1051 try {
1052 // Log the attempt for this specific URL
1053 log.push({ agent, type: "step", message: `Attempting to fetch: ${urlToFetch}` });
1054 const response = await fetch(urlToFetch, {
1055 headers: { "User-Agent": "ValTownPolicyAnalysisBot/1.0 (+http://val.town)" }, // Be a good bot citizen
1056 redirect: "follow", // Follow redirects
1065 status = "success";
1066 // Log success for this URL
1067 log.push({ agent, type: "result", message: `Successfully accessed: ${urlToFetch}` });
1068 return { ...citation, potentialUrl: urlToFetch, traversalStatus: status, error: undefined };
1069 } catch (error) {
1070 errorMsg = `Workspace failed for ${urlToFetch}: ${error.message.substring(0, 100)}`; // Keep error msg concise
1071 // Log failure for this URL
1072 log.push({ agent, type: "error", message: errorMsg });
1073 status = "failed";
1074 return { ...citation, potentialUrl: urlToFetch, traversalStatus: status, error: errorMsg };
1075 }
1076 } else {
1149 log.push({ agent: ingestionAgent, type: "step", message: \`Workspaceing from URL: \${input.documentUrl}\` });
1150 try {
1151 // Basic check for common non-HTTP URL schemes that fetch will reject
1152 if (!input.documentUrl.match(/^https?:\/\//i)) {
1153 throw new Error("Invalid URL scheme. Only http and https are supported.");
1154 }
1155 const response = await fetch(input.documentUrl, {
1156 headers: { "Accept": "text/plain, text/html, application/pdf", "User-Agent": "ValTownPolicyAnalysisBot/1.0" },
1157 redirect: "follow",
1158 timeout: 10000 // 10 second timeout for fetching
1159 });
1160 if (!response.ok) throw new Error(\`HTTP error! Status: \${response.status} \${response.statusText}\`);
1171 } else if (contentType.includes("text/html") || contentType.includes("text/plain") || contentType === "") { // Allow empty content type
1172 const text = await response.text();
1173 if (!text || text.trim().length === 0) throw new Error("Fetched content is empty or not text.");
1174 log.push({
1175 agent: ingestionAgent,
1185
1186 } catch (error) {
1187 const errorMessage = \`Failed to fetch or process URL \${input.documentUrl}: \${error.message}\`;
1188 log.push({ agent: ingestionAgent, type: "error", message: errorMessage });
1189 documentText = null;
vtProjectSearch

vtProjectSearchimport.ts3 matches

@dcm31•Updated 4 days ago
27 if (userId && !processedUsers.has(userId)) {
28 try {
29 // Fetch user data
30 const user = await vt.users.retrieve(userId);
31
43 processedUsers.add(userId);
44 } catch (error) {
45 console.error(`Error fetching user ${userId}:`, error);
46 // Continue with val processing even if user fetch fails
47 }
48 }

myanythingmain.tsx1 match

@yassinreg•Updated 4 days ago
25
26 try {
27 const response = await fetch(window.location.href, {
28 method: 'POST',
29 body: formData

myeverythingmain.tsx1 match

@yassinreg•Updated 4 days ago
25
26 try {
27 const response = await fetch(window.location.href, {
28 method: "POST",
29 body: formData,

feedbackmain.tsx1 match

@yassinreg•Updated 4 days ago
25
26 try {
27 const response = await fetch(window.location.href, {
28 method: "POST",
29 body: formData,

FixItWandindex.http.ts1 match

@wolf•Updated 4 days ago
18 });
19
20export default app.fetch;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago