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=11&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 11117 results for "fetch"(2389ms)

TownieMessages.tsx9 matches

@charmaine•Updated 16 hours ago
219 </>
220 );
221 case "fetch":
222 return (
223 <Details
232 summary={(
233 <>
234 <div>fetch:</div>
235 <div>{args?.valPath}</div>
236 <div>{args?.urlPath || "/"}</div>
238 )}>
239 {result?.type === "success" ? (
240 <div className="fetch-result">
241 <div className="fetch-header">
242 <span className={`status-badge ${result.data.status >= 200 && result.data.status < 300 ? 'success' :
243 result.data.status >= 300 && result.data.status < 400 ? 'redirect' :
247 <span className="response-time">{result.data.responseTime}ms</span>
248 </div>
249 <div className="fetch-section">
250 <h4>Headers</h4>
251 <pre className="fetch-headers">{JSON.stringify(result.data.headers, null, 2)}</pre>
252 </div>
253 <div className="fetch-section">
254 <h4>Response Body</h4>
255 <pre className="fetch-body">
256 {typeof result.data.body === 'object'
257 ? JSON.stringify(result.data.body, null, 2)
261 </div>
262 ) : (
263 <div className="fetch-error">
264 <h4>Error</h4>
265 <pre>{result?.message || "Unknown error"}</pre>

Townieindex.ts1 match

@charmaine•Updated 16 hours ago
21
22// This is the entry point for HTTP vals
23export default app.fetch;
24

Townieindex.ts2 matches

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

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

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

@charmaine•Updated 16 hours 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)[]>([]);
93 if (!messages?.length) return;
94 let last = messages.at(-1);
95 if (shouldRefetch(last)) {
96 refetch();
97 }
98 }, [messages]);
168}
169
170function shouldRefetch (message) {
171 for (let i = 0; i < message?.parts?.length; i++) {
172 let part = message.parts[i];

TownieBranchSelect.tsx1 match

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

staticChessmain.tsx2 matches

@glance•Updated 16 hours ago
11
12 constructor() {}
13 async fetch(req: Request): Promise<Response> {
14 if (new URL(req.url).pathname === "/robots.txt") {
15 return new Response("User-agent: *\nDisallow: /");
248const sc = new StaticChess();
249
250export default analyticsHandlerWrapper(sc.fetch.bind(sc));

untitled-7141index.ts1 match

@riyo•Updated 16 hours ago
267});
268
269export default app.fetch;

Glancer-backup-as-of-5-31demo.ts1 match

@lightweight•Updated 16 hours ago
30 apiUrl.pathname = `/api/demo/${id}`;
31
32 const response = await fetch(apiUrl.toString());
33 const initialData = await response.json();
34

fetch_template2 file matches

@gwoods22•Updated 16 hours ago

HN-fetch-call3 file matches

@ImGqb•Updated 1 day ago
fetch HackerNews by API