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//%22$%7Bad.imageUrl%7D/%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 19032 results for "fetch"(779ms)

Townieproject-files.ts2 matches

@Skywalker•Updated 3 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});

Townieproject-branches.ts2 matches

@Skywalker•Updated 3 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});

Townieopen_townie_prompt_additions.txt1 match

@Skywalker•Updated 3 hours ago
19solution that changes as little code as possible.
20
21Use your 'fetch' tool to debug HTTP vals making requests to them and examining the responses.
22
23Use your 'requests' tool to debug all kinds of vals. It'll show you the logs made during the file execution and the attributes associated it, including headers, http status, run time, error messages and error stack traces.

TownieMessages.tsx9 matches

@Skywalker•Updated 3 hours ago
256 </>
257 );
258 case "fetch":
259 return (
260 <Details
269 summary={(
270 <>
271 <div>fetch:</div>
272 <div>{args?.valPath}</div>
273 <div>{args?.urlPath || "/"}</div>
275 )}>
276 {result?.type === "success" ? (
277 <div className="fetch-result">
278 <div className="fetch-header">
279 <span className={`status-badge ${result.data.status >= 200 && result.data.status < 300 ? 'success' :
280 result.data.status >= 300 && result.data.status < 400 ? 'redirect' :
284 <span className="response-time">{result.data.responseTime}ms</span>
285 </div>
286 <div className="fetch-section">
287 <h4>Headers</h4>
288 <pre className="fetch-headers">{JSON.stringify(result.data.headers, null, 2)}</pre>
289 </div>
290 <div className="fetch-section">
291 <h4>Response Body</h4>
292 <pre className="fetch-body">
293 {typeof result.data.body === 'object'
294 ? JSON.stringify(result.data.body, null, 2)
298 </div>
299 ) : (
300 <div className="fetch-error">
301 <h4>Error</h4>
302 <pre>{result?.message || "Unknown error"}</pre>

Townieindex.ts1 match

@Skywalker•Updated 3 hours ago
220});
221
222export default app.fetch;

Townieindex.ts1 match

@Skywalker•Updated 3 hours ago
27
28// This is the entry point for HTTP vals
29export default app.fetch;
30

Townieindex.ts2 matches

@Skywalker•Updated 3 hours ago
1import { makeChangeValTypeTool } from "./change-val-type.ts";
2import { makeFetchTool } from "./fetch.ts";
3import { makeTextEditorTool } from "./text-editor.ts";
4import { makeTracesTool } from "./traces.ts";
7export {
8 makeChangeValTypeTool,
9 makeFetchTool,
10 makeTextEditorTool,
11 makeTracesTool,

Towniefetch.ts5 matches

@Skywalker•Updated 3 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:
19 "Make an HTTP request to a Val Town val and return the response. Useful for testing HTTP vals. The HTTP response body will be truncated to 5000 characters.",
69 return {
70 type: "error",
71 message: `Error fetching val at path '${valPath}': ${error.message}`,
72 };
73 }
84 return {
85 type: "error",
86 message: `The val at path '${valPath}' is not an HTTP val. Only HTTP vals can be called with fetch.`,
87 };
88 }
115 let response;
116 try {
117 response = await fetch(valEndpoint + normalizedURLPath, options);
118 } catch (error: any) {
119 // Return error information

Townie.cursorrules3 matches

@Skywalker•Updated 3 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

TownieCreditBalance.tsx5 matches

@Skywalker•Updated 3 hours ago
7 const [loading, setLoading] = useState(true);
8
9 const fetchBalance = async () => {
10 try {
11 const response = await fetch("/api/credit-balance");
12 if (response.ok) {
13 const data = await response.json();
15 setBalance(data.balance);
16 } else {
17 console.error("Failed to fetch balance");
18 }
19 } catch (err) {
20 console.error("Error fetching balance:", err);
21 } finally {
22 setLoading(false);
25
26 useEffect(() => {
27 fetchBalance();
28 }, []);
29

FetchBasic2 file matches

@bengold•Updated 2 weeks ago

fetch1 file match

@raify•Updated 2 weeks ago