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/$2?q=fetch&page=20&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 13188 results for "fetch"(1259ms)

Townieindex.ts1 match

@claudiaowusu•Updated 1 day ago
212});
213
214export default app.fetch;

Townieindex.ts1 match

@claudiaowusu•Updated 1 day ago
21
22// This is the entry point for HTTP vals
23export default app.fetch;
24

Townieindex.ts2 matches

@claudiaowusu•Updated 1 day ago
1import { makeChangeValTypeTool } from "./change-val-type.ts";
2import { makeFetchTool } from "./fetch.ts";
3import { makeTextEditorTool } from "./text-editor.ts";
4import { thinkTool } from "./think.ts";
7 makeTextEditorTool,
8 makeChangeValTypeTool,
9 makeFetchTool,
10 thinkTool
11};

Towniefetch.ts5 matches

@claudiaowusu•Updated 1 day ago
11 * Creates a tool for making HTTP requests to vals in a Val Town project
12 */
13export const makeFetchTool = (
14 { bearerToken, project, branch_id }: { bearerToken?: string; project?: any; branch_id?: string } = {},
15) =>
16 tool({
17 name: "fetch",
18 description: "Make an HTTP request to a Val Town val and return the response. Useful for testing HTTP vals.",
19 parameters: z.object({
68 return {
69 type: "error",
70 message: `Error fetching val at path '${valPath}': ${error.message}`,
71 };
72 }
83 return {
84 type: "error",
85 message: `The val at path '${valPath}' is not an HTTP val. Only HTTP vals can be called with fetch.`,
86 };
87 }
111 let response;
112 try {
113 response = await fetch(valEndpoint + urlPath, options);
114 } catch (error: any) {
115 // Return error information

Townie.cursorrules3 matches

@claudiaowusu•Updated 1 day ago
239
240 // Inject data to avoid extra round-trips
241 const initialData = await fetchInitialData();
242 const dataScript = `<script>
243 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
290
291

TownieChatRouteSingleColumn.tsx6 matches

@claudiaowusu•Updated 1 day ago
49 files={project.data?.files}
50 branchId={branchId}
51 refetch={project.refetch}
52 />
53 </ProjectContext>
59 files,
60 branchId,
61 refetch,
62}: {
63 project: any;
64 files: any[];
65 branchId: string;
66 refetch: () => void;
67}) {
68 const [images, setImages] = useState<(string|null)[]>([]);
94 if (!messages?.length) return;
95 let last = messages.at(-1);
96 if (shouldRefetch(last)) {
97 refetch();
98 }
99 }, [messages]);
194}
195
196function shouldRefetch (message) {
197 for (let i = 0; i < message?.parts?.length; i++) {
198 let part = message.parts[i];

TownieBranchSelect.tsx1 match

@claudiaowusu•Updated 1 day ago
32 return;
33 }
34 branches.refetch();
35 if (res?.branch?.id) {
36 navigate(`/chat/${projectId}/branch/${res.branch.id}`);

Chatindex.ts1 match

@c15r•Updated 1 day ago
19});
20
21export default app.fetch;

ChatmcpTesting.ts4 matches

@c15r•Updated 1 day ago
64
65 try {
66 const response = await fetch(server.url, {
67 method: "POST",
68 headers,
97 };
98 }
99 } catch (fetchError: any) {
100 clearTimeout(timeoutId);
101
102 if (fetchError.name === "AbortError") {
103 return {
104 success: false,
107 }
108
109 throw fetchError;
110 }
111 } catch (error: any) {

weatherindex.ts9 matches

@dukky•Updated 1 day ago
19
20 try {
21 const response = await fetch(
22 `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&current=temperature_2m,weather_code,wind_speed_10m,wind_direction_10m,relative_humidity_2m,surface_pressure,visibility,uv_index&hourly=temperature_2m,weather_code,precipitation,wind_speed_10m,wind_direction_10m,relative_humidity_2m&daily=temperature_2m_max,temperature_2m_min,weather_code,precipitation_sum,wind_speed_10m_max,wind_direction_10m_dominant,uv_index_max,sunrise,sunset&timezone=Europe/London`
23 );
68 } catch (error) {
69 console.error("Weather API error:", error);
70 return c.json({ error: "Failed to fetch weather data" }, 500);
71 }
72});
95 const weatherPromises = ukCities.map(async (city) => {
96 try {
97 const response = await fetch(
98 `https://api.open-meteo.com/v1/forecast?latitude=${city.lat}&longitude=${city.lon}&current=temperature_2m,weather_code&timezone=Europe/London`
99 );
113 };
114 } catch (error) {
115 console.error(`Failed to fetch weather for ${city.name}:`, error);
116 return null;
117 }
124 } catch (error) {
125 console.error("Map weather API error:", error);
126 return c.json({ error: "Failed to fetch map weather data" }, 500);
127 }
128});
137 try {
138 // Use Open-Meteo geocoding API with focus on UK
139 const response = await fetch(
140 `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(query)}&count=10&language=en&format=json`
141 );
189 // Inject initial UK weather data to avoid extra round-trips
190 try {
191 const ukWeatherResponse = await fetch(
192 "https://api.open-meteo.com/v1/forecast?latitude=54.5&longitude=-2&current=temperature_2m,weather_code,wind_speed_10m,wind_direction_10m,relative_humidity_2m,surface_pressure,visibility,uv_index&hourly=temperature_2m,weather_code,precipitation,wind_speed_10m,wind_direction_10m,relative_humidity_2m&daily=temperature_2m_max,temperature_2m_min,weather_code,precipitation_sum,wind_speed_10m_max,wind_direction_10m_dominant,uv_index_max,sunrise,sunset&timezone=Europe/London"
193 );
210 html = html.replace("</head>", `${dataScript}</head>`);
211 } catch (error) {
212 console.error("Failed to fetch initial weather data:", error);
213 }
214
216});
217
218export default app.fetch;

proxiedfetch1 file match

@jayden•Updated 12 hours ago

fetch-socials4 file matches

@welson•Updated 4 days ago
fetch and archive my social posts