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/$%7Burl%7D?q=fetch&page=1056&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 13277 results for "fetch"(3835ms)

lucia_honomain.tsx1 match

@saolsenUpdated 9 months ago
548 req: Request,
549): Promise<Response> {
550 return await app.fetch(req);
551}

pr0nmain.tsx7 matches

@roramigatorUpdated 9 months ago
2import React, { useEffect, useState } from "https://esm.sh/react";
3import { createRoot } from "https://esm.sh/react-dom/client";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
5
6const subreddits = ["Battletops", "AverageBattlestations", "desksetup"];
7
8const fetchWithImage = async (subreddit: string) => {
9 const { data: { children } } = await fetchJSON(
10 `https://www.reddit.com/r/${subreddit}.json`,
11 );
24};
25
26const fetchAllReddits = async () => {
27 const posts = (await Promise.all(subreddits.map(fetchWithImage))).flat();
28 return posts;
29};
45
46 useEffect(() => {
47 fetch("/api/posts").then(ok => ok.json())
48 .then(posts => setPosts(posts));
49 }, []);
64export default async function server(req: Request): Promise<Response> {
65 if (req.url.endsWith("/api/posts")) {
66 const posts = await fetchAllReddits();
67 posts.sort((a, b) => b.score - a.score);
68 return Response.json(posts);

OpenAImain.tsx1 match

@arthrodUpdated 9 months ago
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.

valWallmain.tsx9 matches

@iamseeleyUpdated 9 months ago
36
37async function generateGraph(username) {
38 console.log(`Fetching contributions for ${username}`);
39 try {
40 const contributionData = await fetchContributions(username);
41 const totalContributions = Object.values(contributionData).reduce((sum, count) => sum + count, 0);
42 console.log(`Total contributions: ${totalContributions}`);
56}
57
58async function fetchContributions(username) {
59 const contributionMap = {};
60 const valsUrl = `https://api.val.town/v1/alias/${username}/vals`;
61 const valsResponse = await fetch(valsUrl);
62 if (!valsResponse.ok) {
63 throw new Error(`HTTP error! status: ${valsResponse.status}`);
83 contributionMap[creationDate] = (contributionMap[creationDate] || 0) + 1;
84
85 await fetchValVersions(val.id, contributionMap, creationDate);
86 }
87 }
90}
91
92async function fetchValVersions(valId, contributionMap, creationDate) {
93 const versionsUrl = `https://api.val.town/v1/vals/${valId}/versions`;
94 try {
95 const versionsResponse = await fetch(versionsUrl);
96 if (!versionsResponse.ok) {
97 throw new Error(`HTTP ${versionsResponse.status}`);
115 }
116 } catch (error) {
117 console.error(`Failed to fetch versions for val ${valId}:`, error.message);
118 }
119}
199}
200
201export default app.fetch;

spacexapimain.tsx1 match

@moeUpdated 9 months ago
30
31async function loadPage(url) {
32 const response = await fetch(url)
33 const body = await response.text()
34 const $ = cheerio.load(body)

extremePlumCariboumain.tsx15 matches

@ejfoxUpdated 9 months ago
21 setUsername(usernameFromPath || 'ejfox'); // Default to 'ejfox' if no username provided
22
23 const fetchVals = async () => {
24 setLoading(true);
25 setVals([]);
27 setDebugInfo([]);
28 try {
29 setDebugInfo(prev => [...prev, `Fetching vals for ${usernameFromPath || 'ejfox'}...`]);
30 const response = await fetch(`/vals/${usernameFromPath || 'ejfox'}`);
31 if (!response.ok) {
32 throw new Error(`HTTP error! status: ${response.status}`);
40 }
41
42 setDebugInfo(prev => [...prev, `Fetched ${data.vals.length} vals`]);
43
44 // Fetch emojis for each val with a delay
45 for (const val of data.vals) {
46 setDebugInfo(prev => [...prev, `Fetching emoji for ${val.name}...`]);
47 const emoji = await fetchEmojiForName(val.name);
48 setVals(prevVals => [...prevVals, { ...val, emoji }]);
49 await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay
50 }
51
52 setDebugInfo(prev => [...prev, 'All vals and emojis fetched']);
53 } catch (error) {
54 console.error('Error fetching vals:', error);
55 setError(error.toString());
56 setDebugInfo(prev => [...prev, `Error: ${error.message}`]);
60 };
61
62 fetchVals();
63 }, []);
64
119}
120
121async function fetchEmojiForName(name) {
122 try {
123 const response = await fetch(`/emoji/${encodeURIComponent(name)}`);
124 if (response.ok) {
125 const data = await response.json();
126 return data.emoji;
127 }
128 console.error('Error fetching emoji:', response.statusText);
129 } catch (error) {
130 console.error('Error fetching emoji:', error);
131 }
132 return '❓'; // Placeholder
172 for await (const val of client.users.vals.list(user.id, { limit: 100 })) {
173 vals.push(val);
174 await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay between fetches
175 }
176

allvalsindexmain.tsx2 matches

@ejfoxUpdated 9 months ago
19
20 useEffect(() => {
21 fetch('/vals')
22 .then(response => {
23 if (!response.ok) {
39 })
40 .catch(error => {
41 console.error('Error fetching vals:', error);
42 setError(error.toString());
43 setLoading(false);

sqliteExplorerAppmain.tsx4 matches

@febUpdated 9 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/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 })));

blob_adminmain.tsx2 matches

@snptrsUpdated 9 months ago
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));

sketchmain.tsx1 match

@ff6347Updated 9 months ago
11 const imageUrl = "https://charlypoly-httpapiscreenshotpageexample.web.val.run/?url=" + url.origin
12 // return Response.redirect(imageUrl, 302)
13 const res = await fetch(imageUrl)
14 const blob = await res.blob()
15 return new Response(blob, { headers: { "Content-Type": "image/png" } })

GithubPRFetcher

@andybakUpdated 13 hours ago

proxiedfetch1 file match

@jaydenUpdated 1 day ago