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/image-url.jpg%20%22Optional%20title%22?q=fetch&page=3&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 8213 results for "fetch"(480ms)

OpenTowniesend-message.ts3 matches

@charmaine•Updated 2 hours 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 }

OpenTownieproject-files.ts2 matches

@charmaine•Updated 2 hours ago
30 return c.json({ files: files.data });
31 } catch (error) {
32 console.error("Error fetching project files:", error);
33 return Response.json({ error: "Failed to fetch project files" }, { status: 500 });
34 }
35});

OpenTownieproject-branches.ts2 matches

@charmaine•Updated 2 hours ago
21 return c.json({ branches: branches.data });
22 } catch (error) {
23 console.error("Error fetching branches:", error);
24 return Response.json({ error: "Failed to fetch branches" }, { status: 500 });
25 }
26});

OpenTownieindex.ts1 match

@charmaine•Updated 2 hours ago
62});
63
64export default app.fetch;
65

OpenTownieChatRoute.tsx8 matches

@charmaine•Updated 2 hours ago
46 files={project.data?.files}
47 branchId={branchId}
48 refetch={project.refetch}
49 />
50 </>
56 files,
57 branchId,
58 refetch,
59}: {
60 project: any;
61 files: any[];
62 branchId: string;
63 refetch: () => void;
64}) {
65 const { token, anthropicApiKey } = useAuth();
93 if (!messages?.length) return;
94 let last = messages.at(-1);
95 if (shouldRefetch(last)) {
96 refetch();
97 }
98 }, [messages]);
177}
178
179function shouldRefetch (message) {
180 for (let i = 0; i < message?.parts?.length; i++) {
181 let part = message.parts[i];
184 case "str_replace_editor":
185 if (part.toolInvocation?.args?.command === "create") {
186 // console.log("REFETCH (create)");
187 return true;
188 }
190 case "delete_file":
191 case "change_val_type":
192 // console.log("REFETCH (change type or delete)");
193 return true;
194 }

OpenTownieBranchSelect.tsx1 match

@charmaine•Updated 2 hours ago
33 return;
34 }
35 branches.refetch();
36 if (res?.branch?.id) {
37 navigate(`/chat/${projectId}/branch/${res.branch.id}`);

IClickWolfindex.ts2 matches

@vtTestLocal•Updated 2 hours 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;

blog2025-04-08-migration.md2 matches

@fil•Updated 4 hours 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,

blogproxy.ts1 match

@fil•Updated 4 hours ago
9
10 // Proxy the request to the old blog
11 const response = await fetch(
12 new Request(OLD_BLOG_URL + url.pathname + url.search, {
13 method: c.req.method,

bloglive-reload.ts3 matches

@fil•Updated 4 hours ago
32
33/**
34 * Creates a wrapper around a fetch handler that injects a script tag into HTML responses
35 *
36 * @param handler The original fetch handler function
37 * @param scriptContent The HTML content to inject
38 * @returns A new fetch handler with HTML rewriting capability
39 */
40export function injectHTML(

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago