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/?q=fetch&page=29&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 2446 results for "fetch"(356ms)

vt-blog2025-04-08-migration.md2 matches

@shouser•Updated 6 days ago
83We didn't. We left them where they are, and proxy to them.
84
85Writing a proxy in Val Town (or any functions platform with the ['fetch handler' interface](https://blog.val.town/blog/the-api-we-forgot-to-name/)) is a delight:
86
87```ts
89export async function proxy(req: Request): Promise<Response> {
90 const url = new URL(req.url);
91 return fetch(OLD_BLOG_HOST + url.pathname + url.search, {
92 method: req.method,
93 headers: req.headers,

FarcasterGalleryimage.tsx2 matches

@moe•Updated 6 days ago
75 const fontPromises = fontsConfig.map(async (font) => {
76 const fontUrl = "https://cdn.jsdelivr.net/npm/@tamagui/font-inter@1.108.3/otf/" + font.fontFile;
77 const fontArrayBuf = await fetch(fontUrl).then((res) => res.arrayBuffer());
78 return { name: font.name, data: fontArrayBuf, weight: font.weight };
79 });
86 // const api = `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${code.toLowerCase()}.svg`
87 const api = `https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${code.toLowerCase()}_color.svg`;
88 return fetch(api).then((r) => r.text());
89};
90

FarcasterGalleryfarcaster.ts1 match

@moe•Updated 6 days ago
85
86async function sendFarcasterNotification(payload: any) {
87 return await fetch("https://api.warpcast.com/v1/frame-notifications", {
88 method: "POST",
89 headers: { "Content-Type": "application/json" },

FarcasterGalleryindex.tsx2 matches

@moe•Updated 6 days ago
70});
71
72// HTTP vals expect an exported "fetch handler"
73// This is how you "run the server" in Val Town with Hono
74export default app.fetch;

FarcasterSpacesindex.tsx4 matches

@moe•Updated 6 days ago
6import { embedMetadata, handleFarcasterEndpoints, name } from "./farcaster.ts";
7import { handleImageEndpoints } from "./image.tsx";
8import { fetchGet as fetchNeynarGet } from "./neynar.ts";
9
10const app = new Hono();
25 const url = new URL(c.req.url);
26 const path = url.searchParams.get("path");
27 const response = await fetchNeynarGet(path).then(r => r.json());
28 return c.json(response);
29});
70});
71
72// HTTP vals expect an exported "fetch handler"
73// This is how you "run the server" in Val Town with Hono
74export default app.fetch;

OpenTownieuseProjectFiles.ts4 matches

@jxnblk•Updated 6 days ago
1import { useState, useEffect } from "https://esm.sh/react@18.2.0?dev";
2import { fetchProjectFiles } from "../utils/api.ts";
3
4interface UseProjectFilesProps {
15
16/**
17 * Custom hook to fetch and manage project files
18 */
19export function useProjectFiles({
38
39 try {
40 const filesData = await fetchProjectFiles({
41 bearerToken,
42 projectId,
51 }
52 } catch (err) {
53 console.error("Error fetching project files:", err);
54 setProjectFiles([]);
55 setError(err instanceof Error ? err : new Error(String(err)));

OpenTownietext-editor.ts1 match

@jxnblk•Updated 6 days ago
136 let type_: "file" | "http" | "script";
137 if (path.includes("backend/index.ts")) type_ = "http";
138 if (file_text?.includes("export default app.fetch")) type_ = "http";
139 if ([".ts", ".tsx", ".js", ".jsx"].some(ext => path.endsWith(ext))) {
140 type_ = "script";

OpenTowniesystem_prompt.txt3 matches

@jxnblk•Updated 6 days ago
233
234 // Inject data to avoid extra round-trips
235 const initialData = await fetchInitialData();
236 const dataScript = `<script>
237 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
280
2815. **API Design:**
282 - `fetch` handler is the entry point for HTTP vals
283 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

OpenTowniesend-message.ts3 matches

@jxnblk•Updated 6 days ago
95 }
96
97 // If there are selected files, fetch their content and add them to the messages
98 if (selectedFiles && selectedFiles.length > 0) {
99 const vt = new ValTown({ bearerToken });
115 fileContents += `## File: ${filePath}\n\`\`\`\n${fileWithLinesNumbers(content)}\n\`\`\`\n\n`;
116 } catch (error) {
117 console.error(`Error fetching file ${filePath}:`, error);
118 fileContents += `## File: ${filePath}\nError: Could not fetch file content\n\n`;
119 }
120 }

OpenTownieProjects.tsx1 match

@jxnblk•Updated 6 days ago
10
11async function loader({ bearerToken }: { bearerToken: string }) {
12 const data = await (await fetch("/api/projects-loader", {
13 headers: {
14 "Authorization": "Bearer " + bearerToken,

fetchPaginatedData2 file matches

@nbbaier•Updated 5 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago