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=204&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 2746 results for "fetch"(393ms)

forky_1742579787862index.ts2 matches

@shouser•Updated 1 month ago
232});
233
234// HTTP vals expect an exported "fetch handler"
235// This is how you "run the server" in Val Town with Hono
236export default app.fetch;

forkyindex.ts2 matches

@shouser•Updated 1 month ago
232});
233
234// HTTP vals expect an exported "fetch handler"
235// This is how you "run the server" in Val Town with Hono
236export default app.fetch;

tangledNetmain.tsx11 matches

@hrbrmstr•Updated 1 month ago
246 }, [isDarkMode]);
247
248 const fetchFollowGraph = async () => {
249 if (!startHandle.trim()) return;
250
255
256 try {
257 const response = await fetch("/fetch-graph", {
258 method: "POST",
259 body: JSON.stringify({ handle: startHandle }),
264 setProgress(`Found ${sortedEdges.length} connections.`);
265 } catch (error) {
266 setProgress("Error fetching graph");
267 console.error(error);
268 } finally {
321 onKeyDown={(e) => {
322 if (e.key === "Enter" && !isLoading && startHandle.trim()) {
323 fetchFollowGraph();
324 }
325 }}
332 />
333 <button
334 onClick={fetchFollowGraph}
335 disabled={isLoading || !startHandle.trim()}
336 style={{
461
462export default async function server(request: Request): Promise<Response> {
463 if (request.method === "POST" && new URL(request.url).pathname === "/fetch-graph") {
464 const { handle } = await request.json();
465
478 async function didToHandle(did: string) {
479 try {
480 const plcResponse = await fetch(`https://plc.directory/${encodeURIComponent(did)}`);
481 const plcData = await plcResponse.json();
482 return plcData.alsoKnownAs[0]?.replace("at://", "") || did;
487 }
488
489 async function fetchFollowGraph(startDid: string, maxDepth = 4) {
490 const visited = new Set<string>();
491 const uniqueEdges = new Set<string>();
499
500 try {
501 const plcResponse = await fetch(`https://plc.directory/${encodeURIComponent(did)}`);
502 const plcData = await plcResponse.json();
503 const serviceEndpoint = plcData.service.find(
507 if (!serviceEndpoint) return;
508
509 const followsResponse = await fetch(
510 `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${
511 encodeURIComponent(
553 }
554
555 const graph = await fetchFollowGraph(startDid);
556 return new Response(JSON.stringify(graph), {
557 headers: { "Content-Type": "application/json" },

HTTP101put2 matches

@willthereader•Updated 1 month ago
62
63 <script>
64 // Function to handle the PUT request using Fetch API
65 async function updateName() {
66 const oldName = document.getElementById('oldNameInput').value;
77
78 try {
79 const response = await fetch(window.location.href, {
80 method: 'PUT',
81 body: formData

BlackJackfrontend.html3 matches

@stevekrouse•Updated 1 month ago
62 }
63
64 // Fetch the greeting from the API
65 const response = await fetch(url);
66
67 if (!response.ok) {
76 document.getElementById('result').classList.remove('hidden');
77 } catch (error) {
78 console.error('Error fetching greeting:', error);
79 alert('Failed to get greeting. Please try again.');
80 }

BlackJackindex.ts1 match

@stevekrouse•Updated 1 month ago
44
45// Export the app as the default handler
46export default app.fetch;

BlackJackApp.tsx8 matches

@stevekrouse•Updated 1 month ago
37 const [result, setResult] = useState<string>("");
38
39 // Fetch the current game state
40 const fetchGameState = async () => {
41 try {
42 const res = await fetch("/api/state");
43 const data = await res.json();
44
78 setLoading(true);
79 try {
80 const res = await fetch("/api/start", { method: "POST" });
81 const data = await res.json();
82 setGameState(data);
97 setLoading(true);
98 try {
99 const res = await fetch("/api/hit", { method: "POST" });
100 const data = await res.json();
101 setGameState(data);
118 setLoading(true);
119 try {
120 const res = await fetch("/api/stand", { method: "POST" });
121 const data = await res.json();
122 setGameState(data);
145 setLoading(true);
146 try {
147 const res = await fetch("/api/booze", { method: "POST" });
148 const data = await res.json();
149 setGameState(data);
163 // Initial load
164 useEffect(() => {
165 fetchGameState();
166 }, []);
167
askSMHI

askSMHIapi1 match

@ljus•Updated 1 month ago
12 return c.json(weatherResponse);
13});
14export default app.fetch;

reactHonoStarterindex.ts2 matches

@vawogbemi•Updated 1 month 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;

cerebras_coderindex1 match

@Shailesh•Updated 1 month ago
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago