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/$1?q=fetch&page=51&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 13582 results for "fetch"(1884ms)

hallwayEmbedPokemonindex.html4 matches

@matt_hallway•Updated 4 days ago
25
26 async function main() {
27 const count = await fetch("https://pokeapi.co/api/v2/pokemon")
28 .then(res => res.json())
29 .then(json => json.count)
30
31 const fetchPokemon = async (index) => {
32 const pokemon = await fetch(`https://pokeapi.co/api/v2/pokemon/${index}`)
33 .then(res => res.json())
34
38 btn.onclick = async () => {
39 const index = randomIntFromInterval(1, 500)
40 const pokemon = await fetchPokemon(index)
41
42 sprite.src = pokemon.sprites.front_default

hallwayEmbedPokemonserver.ts1 match

@matt_hallway•Updated 4 days ago
11);
12
13export default app.fetch;

helloStaticSitemain.ts2 matches

@matt_hallway•Updated 4 days ago
16});
17
18// HTTP vals expect an exported "fetch handler"
19// This is how you "run the server" in Val Town with Hono
20export default app.fetch;

gemini-testmain.tsx1 match

@talkbot•Updated 4 days ago
79
80 try {
81 const geminiResponse = await fetch(targetUrl, {
82 method: req.method,
83 headers: headersToGemini,

pinboardviewerindex.ts1 match

@flymaster•Updated 4 days ago
201 <div class="bg-white p-8 rounded-lg shadow-md max-w-md">
202 <h1 class="text-2xl font-bold text-red-600 mb-4">Error</h1>
203 <p class="text-gray-600 mb-4">Failed to fetch data from the pins table.</p>
204 <p class="text-sm text-gray-500">Error: ${escapeHtml(error.message)}</p>
205 <a href="/"

untitled-2689main.tsx13 matches

@wahobd•Updated 4 days ago
604 const triggerTelegramInteraction = async (chatId) => {
605 try {
606 const response = await fetch("/handle-telegram-interaction", {
607 method: "POST",
608 headers: { "Content-Type": "application/json" },
621 };
622
623 const fetchUserBalance = async () => {
624 let userId = null;
625 let isTelegramEnv = false;
674 if (userId) {
675 try {
676 const response = await fetch(`/get-balance?uid=${userId}`);
677 if (!response.ok) {
678 try {
699 }
700 } catch (error) {
701 console.error("Failed to fetch or process balance:", error.toString());
702 setBalance("Error");
703 }
704 } else {
705 console.error("User ID could not be determined for balance fetching.");
706 setBalance("--.--");
707 }
727 window.Telegram.WebApp.ready();
728 }
729 fetchUserBalance();
730 } else if (isTelegramWebAppPresent) {
731 console.log(
732 "Telegram script present, but user data not immediately available or ready() pending. Setting timeout for balance fetch.",
733 );
734 if (window.Telegram.WebApp.ready) {
735 window.Telegram.WebApp.ready();
736 }
737 scriptLoadTimeoutId = setTimeout(fetchUserBalance, 300);
738 } else {
739 console.log("Not in Telegram environment. Proceeding as web user for balance fetch.");
740 fetchUserBalance();
741 }
742 }
878 setShowSpinner(true);
879
880 const response = await fetch("/save-credentials", {
881 method: "POST",
882 headers: { "Content-Type": "application/json" },
1880 const sendActualTelegramAPIMessage = async (botToken, chatId, text, parseMode = "Markdown") => {
1881 try {
1882 const response = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
1883 method: "POST",
1884 headers: { "Content-Type": "application/json" },
2190 if (confirm('Are you sure you want to unban this user?')) {
2191 try {
2192 const response = await fetch('/unban-telegram-user', {
2193 method: 'POST',
2194 headers: { 'Content-Type': 'application/json' },

proxiedfetchmain.tsx2 matches

@jayden•Updated 4 days ago
1import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
2
3export default async function (req: Request): Promise<Response> {
28
29 try {
30 const upstream = await proxiedFetch(target, init);
31 // Stream status, statusText, headers, and body back to the client
32 return new Response(upstream.body, {

leglmain.tsx11 matches

@join•Updated 4 days ago
264 <textarea id="legal-task-query" name="legalTaskQuery" placeholder="E.g., 'Identify all clauses related to termination for cause.' or 'Summarize the key obligations of Party A.'">${escapedQuery}</textarea>
265
266 <label for="doc-url">Document URL (Optional - content will be fetched):</label>
267 <input type="text" id="doc-url" name="documentUrl" value="${escapedUrl}" placeholder="https://example.com/legal-document.html">
268
491 inputSourceDescription = \`URL: \${urlValue}\`;
492 formData.append('documentUrl', urlValue);
493 addStatusMessage(\`Fetching and processing content from URL: \${urlValue}\`, 'progress');
494 }
495 formData.append('inputSourceDescription', inputSourceDescription);
498 try {
499 // The Val itself acts as the API endpoint
500 const response = await fetch(window.location.pathname + '?format=json', {
501 method: 'POST',
502 // FormData sets Content-Type automatically
568 const { OpenAI } = await import("https://esm.town/v/std/openai");
569 const { z } = await import("npm:zod"); // For potential future robust input validation on server
570 const { fetch } = await import("https://esm.town/v/std/fetch");
571 const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract");
572
692 documentText = input.documentText;
693 } else if (input.documentUrl) {
694 log.push({ agent: ingestionAgent, type: "step", message: `Fetching from URL: ${input.documentUrl}` });
695 try {
696 // Basic fetch, consider adding User-Agent, timeout, error handling, content-type checking
697 const response = await fetch(input.documentUrl, {
698 headers: { "Accept": "text/plain, text/html, application/pdf" },
699 }); // Accept PDF too
702 const contentType = response.headers.get("content-type") || "";
703 if (contentType.includes("application/pdf")) {
704 log.push({ agent: ingestionAgent, type: "info", message: "Fetched PDF from URL. Extracting text..." });
705 const pdfBuffer = await response.arrayBuffer();
706 documentText = await extractPdfTextNative(
715 } else { // Assume text-like
716 const text = await response.text();
717 if (!text || text.trim().length === 0) throw new Error("Fetched content is empty or not text.");
718 log.push({ agent: ingestionAgent, type: "info", message: `Fetched ~${text.length} characters from URL.` });
719 documentText = text;
720 }
721 } catch (error) {
722 const errorMessage = `Failed to fetch or process URL ${input.documentUrl}: ${error.message}`;
723 log.push({ agent: ingestionAgent, type: "error", message: errorMessage });
724 documentText = null;

cerebras_coderv3index.ts1 match

@etomberg391•Updated 4 days ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

TownieuseUser.tsx4 matches

@PrincessJossy•Updated 4 days ago
8 const [error, setError] = useState(null);
9
10 const fetchData = async () => {
11 try {
12 const userEndpoint = new URL(USER_ENDPOINT, window.location.origin);
13
14 const res = await fetch(userEndpoint);
15 const data = await res.json();
16 if (!res.ok) {
33
34 useEffect(() => {
35 fetchData();
36 }, []);
37
38 return { data, loading, error, refetch: fetchData };
39}
40

FetchBasic2 file matches

@ther•Updated 9 hours ago

GithubPRFetcher

@andybak•Updated 3 days ago