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/image-url.jpg?q=fetch&page=122&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 9478 results for "fetch"(977ms)

stevensDemoindex.ts2 matches

@cduke•Updated 1 week ago
135 ));
136
137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;

stevensDemo.cursorrules5 matches

@cduke•Updated 1 week ago
163```
164
1655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169
242
243 // Inject data to avoid extra round-trips
244 const initialData = await fetchInitialData();
245 const dataScript = `<script>
246 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
300
3015. **API Design:**
302 - `fetch` handler is the entry point for HTTP vals
303 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304 - Properly handle CORS if needed for external access

stevensDemoApp.tsx17 matches

@cduke•Updated 1 week ago
82 const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
83
84 // Fetch images from backend instead of blob storage directly
85 useEffect(() => {
86 // Set default background color in case image doesn't load
89 }
90
91 // Fetch avatar image
92 fetch("/api/images/stevens.jpg")
93 .then((response) => {
94 if (response.ok) return response.blob();
103 });
104
105 // Fetch wood background
106 fetch("/api/images/wood.jpg")
107 .then((response) => {
108 if (response.ok) return response.blob();
129 }, []);
130
131 const fetchMemories = useCallback(async () => {
132 setLoading(true);
133 setError(null);
134 try {
135 const response = await fetch(API_BASE);
136 if (!response.ok) {
137 throw new Error(`HTTP error! status: ${response.status}`);
154 }
155 } catch (e) {
156 console.error("Failed to fetch memories:", e);
157 setError(e.message || "Failed to fetch memories.");
158 } finally {
159 setLoading(false);
162
163 useEffect(() => {
164 fetchMemories();
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
176
177 try {
178 const response = await fetch(API_BASE, {
179 method: "POST",
180 headers: { "Content-Type": "application/json" },
188 setNewMemoryTags("");
189 setShowAddForm(false);
190 await fetchMemories();
191 } catch (e) {
192 console.error("Failed to add memory:", e);
199
200 try {
201 const response = await fetch(`${API_BASE}/${id}`, {
202 method: "DELETE",
203 });
205 throw new Error(`HTTP error! status: ${response.status}`);
206 }
207 await fetchMemories();
208 } catch (e) {
209 console.error("Failed to delete memory:", e);
231
232 try {
233 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234 method: "PUT",
235 headers: { "Content-Type": "application/json" },
240 }
241 setEditingMemory(null);
242 await fetchMemories();
243 } catch (e) {
244 console.error("Failed to update memory:", e);

Discord_Bot_Servicesmap-vote-tallying.tsx1 match

@ktodaz•Updated 1 week ago
68 return rateLimitService.executeWithRateLimit(routeKey, async () => {
69 console.log(`🔄 Sending request to ${url}`);
70 const response = await fetch(url, {
71 ...options,
72 headers,
28
29 console.log(`🔄 Sending request to ${url}`);
30 const response = await fetch(url, {
31 ...options,
32 headers,
luciaMagicLinkStarter

luciaMagicLinkStarterindex.ts2 matches

@stevekrouse•Updated 1 week ago
24});
25
26// HTTP vals expect an exported "fetch handler"
27// This is how you "run the server" in Val Town with Hono
28export default app.fetch;
66 return rateLimitService.executeWithRateLimit(routeKey, async () => {
67 console.log(`🔄 Sending request to ${url}`);
68 const response = await fetch(url, {
69 ...options,
70 headers,
109 const token = Deno.env.get("DISCORD_BOT_TOKEN");
110
111 const response = await fetch(url, {
112 method: "PUT",
113 headers: {

crypto-geminiscript.tsx11 matches

@hexmanshu•Updated 1 week ago
2// Make sure to set the COINGECKO_API_KEY environment variable in Val Town
3
4import { fetch } from "npm:undici"; // Use undici for fetch in Node.js environment
5
6interface CoinGeckoMarketCoin {
57const FNG_API_URL = "https://api.alternative.me/fng/?limit=1";
58
59async function fetchFromApi<T>(url: string, isCoinGecko: boolean = true): Promise<T | null> {
60 const headers: HeadersInit = {};
61 if (isCoinGecko && COINGECKO_API_KEY) {
65
66 try {
67 const response = await fetch(url, { headers });
68 if (!response.ok) {
69 const errorText = await response.text();
73 return await response.json() as T;
74 } catch (error) {
75 console.error(`Network or Fetch Error for ${url}: `, error);
76 return null;
77 }
100 topCoinsData,
101 ] = await Promise.all([
102 fetchFromApi<CoinGeckoMarketCoin[]>(`${COINGECKO_API_BASE}/coins/markets?vs_currency=usd&ids=bitcoin`),
103 fetchFromApi<CoinGeckoChartData>(
104 `${COINGECKO_API_BASE}/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily`,
105 ),
106 fetchFromApi<FearAndGreedData>(FNG_API_URL, false), // false for isCoinGecko
107 fetchFromApi<CoinGeckoGlobalData>(`${COINGECKO_API_BASE}/global`),
108 fetchFromApi<CoinGeckoMarketCoin[]>(
109 `${COINGECKO_API_BASE}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=10&page=1&sparkline=true&price_change_percentage=7d`,
110 ),
124 });
125 } catch (error) {
126 console.error("Error fetching dashboard data:", error);
127 return new Response(JSON.stringify({ error: "Failed to fetch dashboard data" }), {
128 headers: { ...corsHeaders, "Content-Type": "application/json" },
129 status: 500,

dood-redirectmain.tsx1 match

@temptemp•Updated 1 week ago
16});
17
18export default app.fetch;

mastodon-pogodanew-file-2457.tsx4 matches

@tomasz•Updated 1 week ago
1const mastodonToken = Deno.env.get("MASTODON_ACCESS_TOKEN");
2
3import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
4import { load } from "npm:cheerio";
5
6async function mastodonWeatherMap() {
7 const html = await fetchText("https://www.bankier.pl//gielda/notowania/indeksy-gpw"); // Przykład linku do strony z ETF-ami
8 const $ = load(html);
9
36const status = await mastodonWeatherMap();
37
38const html = await fetchText(
39 "https://www.bankier.pl//gielda/notowania/indeksy-gpw",
40);
47console.log("lol");
48
49await fetch(`https://mastodon.social/api/v1/statuses`, {
50 method: "POST",
51 headers: {

agentplex-deal-flow-email-fetch1 file match

@anandvc•Updated 3 hours ago

proxyFetch2 file matches

@vidar•Updated 2 days ago