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=180&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 4661 results for "fetch"(355ms)

blogindex.ts2 matches

@cdignam•Updated 3 weeks ago
34});
35
36// Export the fetch handler for Val Town
37export default liveReload(app.fetch, import.meta.url);

blog2025-04-08-migration.md2 matches

@cdignam•Updated 3 weeks 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,

sqliteExplorerAppmain.tsx4 matches

@charmaine•Updated 3 weeks ago
1/** @jsxImportSource npm:hono/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

chatindex.ts1 match

@loading•Updated 3 weeks ago
55
56// Export the Hono app
57export default app.fetch;

chatApp.tsx1 match

@loading•Updated 3 weeks ago
56
57 try {
58 const response = await fetch('/api/chat', {
59 method: 'POST',
60 headers: {

blog2025-04-08-migration.md2 matches

@valdottown•Updated 3 weeks 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,

vt-blogproxy.ts1 match

@stevekrouse•Updated 3 weeks 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,

vt-bloglive-reload.ts3 matches

@stevekrouse•Updated 3 weeks 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(

imgmain.ts1 match

@loading•Updated 3 weeks ago
48 },
49 "/:user": async (_req: any, _, { user }: any) => {
50 const res = await (await fetch("https://api.val.town/v1/users/" + user)).json();
51 return Response.redirect(res.profileImageUrl);
52 },

newestmain.ts9 matches

@loading•Updated 3 weeks ago
17 const offset = c.req.query("offset") ? parseInt(c.req.query("offset")) : 0;
18
19 const response = await fetch(`https://api.val.town/v1/projects?limit=${limit}&offset=${offset}`);
20
21 if (!response.ok) {
22 throw new Error(`Failed to fetch vals: ${response.status} ${response.statusText}`);
23 }
24
29 // + "/README.md";
30 // try {
31 // const res = await fetch(url);
32 // if (!res.ok) {
33 // throw new Error(`Failed to fetch val: ${response.status} ${response.statusText}`);
34 // }
35 // const text = await res.text();
36 // val.description = await res.text();
37 // } catch (error) {
38 // console.error("Error fetching val description:", error);
39 // }
40 // if (!response.ok) {
41 // throw new Error(`Failed to fetch val: ${response.status} ${response.statusText}`);
42 // }
43 // }
45 return c.json(data);
46 } catch (error) {
47 console.error("Error fetching vals:", error);
48 return c.json({ error: "Failed to fetch vals" }, 500);
49 }
50});
56app.get("/frontend/**/*", (c: any) => serveFile(c.req.path, import.meta.url));
57
58export default app.fetch;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago