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=478&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 8214 results for "fetch"(955ms)

BTCPriceCheckermain.tsx8 matches

@ericxyz86•Updated 5 months ago
15
16 useEffect(() => {
17 async function fetchCryptoPrices() {
18 try {
19 // Fetch Bitcoin price from CoinDesk
20 const bitcoinResponse = await fetch('https://api.coindesk.com/v1/bpi/currentprice/USD.json');
21 const bitcoinData = await bitcoinResponse.json();
22 const bitcoinPrice = bitcoinData.bpi.USD.rate_float;
23
24 // Fetch Solana price from CoinGecko (free API)
25 const solanaResponse = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd');
26 const solanaData = await solanaResponse.json();
27 const solanaPrice = solanaData.solana.usd;
39 setLastUpdated(new Date());
40 } catch (err) {
41 setError('Could not fetch cryptocurrency prices');
42 console.error(err);
43 }
44 }
45
46 fetchCryptoPrices();
47 const interval = setInterval(fetchCryptoPrices, 60000); // Update every minute
48 return () => clearInterval(interval);
49 }, []);

oldProjectsmain.tsx1 match

@willthereader•Updated 5 months ago
94app.get("/projects/Debugging_Guide", Debugging_Guide);
95
96export default app.fetch;

helpfulFuchsiaAmphibianmain.tsx5 matches

@Handlethis•Updated 5 months ago
9
10 useEffect(() => {
11 async function fetchContent() {
12 try {
13 // Generate AI audio description
26 setAudioDescription(audioDescCompletion.choices[0].message.content || "AI continues to revolutionize audio generation with innovative technologies in music composition, voice synthesis, and sound design.");
27
28 // Fetch AI-generated image
29 const imageUrl = "https://maxm-imggenurl.web.val.run/AI technology visualization with abstract digital elements representing machine learning and neural networks";
30 const response = await fetch(imageUrl);
31
32 if (!response.ok) {
36 setGeneratedImage(imageUrl);
37 } catch (error) {
38 console.error("Error fetching AI content:", error);
39 setGeneratedImage("https://maxm-imggenurl.web.val.run/AI technology visualization with abstract digital elements representing machine learning and neural networks");
40 }
41 }
42
43 fetchContent();
44 }, []);
45

test_explorermain.tsx5 matches

@willthereader•Updated 5 months ago
10}
11return "Basic addition test passed!";`,
12 async: `// Test an async function that fetches data
13const data = await module.fetchData();
14if (!Array.isArray(data) || data.length === 0) {
15 throw new Error("Expected non-empty array");
16}
17return \`Fetched \${data.length} items successfully\`;`,
18 error: `// Test error handling
19try {
36 const runTests = async () => {
37 try {
38 const response = await fetch("/run-tests", {
39 method: "POST",
40 headers: { "Content-Type": "application/json" },
133 } catch (error) {
134 console.error("Error in runTests:", error);
135 if (error instanceof TypeError && error.message.includes("Failed to fetch dynamically imported module")) {
136 return {
137 success: false,

breakdownmain.tsx16 matches

@yawnxyz•Updated 5 months ago
165 ]
166
167 const response = await fetch(pipeline_url, {
168 method: "POST",
169 headers: {
192
193
194// Add new route for fetching source content
195export const fetchSource = async (c) => {
196 const body = await c.req.json();
197 const url = body.url;
212
213 try {
214 const response = await fetch(pipeline_url, {
215 method: "POST",
216 headers: { "Content-Type": "application/json" },
223
224 if (!response.ok) {
225 throw new Error(`Failed to fetch content from ${url}`);
226 }
227
229 return c.json({ content: result.content || result.text || result });
230 } catch (error) {
231 console.error(`Error fetching source ${url}:`, error);
232 return c.json({ error: error.message }, 500);
233 }
328// app.post("/execute", execute);
329app.post("/execute2", execute2);
330app.post("/fetch-source", fetchSource);
331
332const module = `
400 },
401
402 async fetchSourceContent(url) {
403 try {
404 console.log('[fetchSourceContent] url:', url);
405 const response = await fetch('/fetch-source', {
406 method: 'POST',
407 headers: { 'Content-Type': 'application/json' },
409 });
410
411 if (!response.ok) throw new Error('Failed to fetch content from URL');
412 const result = await response.json();
413 if (result.error) throw new Error(result.error);
414 return result.content;
415 } catch (error) {
416 console.error('Error fetching source:', error);
417 return null;
418 }
467 if (this.isValidUrl(textToProcess)) {
468 originalUrl = textToProcess;
469 const content = await this.fetchSourceContent(textToProcess);
470 if (!content) throw new Error('Failed to fetch content from URL');
471 textToProcess = content;
472 }
473
474 const response = await fetch('/execute2', {
475 method: 'POST',
476 headers: { 'Content-Type': 'application/json' },
715app.get("/", (c) => c.html(html));
716
717export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
718
719

lastloginmain.tsx2 matches

@stevekrouse•Updated 5 months ago
94 tokenUrl.searchParams.set("state", store.state);
95
96 const tokenResp = await fetch(tokenUrl.toString());
97 if (!tokenResp.ok) {
98 throw new Error(await tokenResp.text());
103 };
104
105 const resp = await fetch("https://lastlogin.net/userinfo", {
106 headers: {
107 Authorization: `Bearer ${access_token}`,

FetchBasicREADME.md2 matches

@stevekrouse•Updated 5 months ago
1# Framer Fetch: Basic
2
3A basic example of an API endpoint to use with Framer Fetch. CORS headers are permissive by default on Val Town, so no need to set them.

cerebras_codermain.tsx7 matches

@ruudzon•Updated 5 months ago
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
128
129 useEffect(() => {
130 async function fetchUsageStats() {
131 const response = await fetch("/usage-stats");
132 const data = await response.json();
133 setUsageStats(data);
134 }
135 fetchUsageStats();
136 }, []);
137
141
142 try {
143 const response = await fetch("/", {
144 method: "POST",
145 body: JSON.stringify({

lazyCookmain.tsx3 matches

@karkowg•Updated 5 months ago
20 setError("");
21 try {
22 const response = await fetch("/recipes", {
23 method: "POST",
24 headers: { "Content-Type": "application/json" },
32 }
33 } catch (err) {
34 setError("An error occurred while fetching recipes. Please try again.");
35 } finally {
36 setLoading(false);
339
340async function generateImage(recipeName: string): Promise<string> {
341 const response = await fetch(`https://maxm-imggenurl.web.val.run/${encodeURIComponent(recipeName)}`);
342 if (!response.ok) {
343 throw new Error(`Failed to generate image for ${recipeName}`);

RepresentingAJokemain.tsx5 matches

@lentinimojchers•Updated 5 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4// Fetches a random joke.
5async function fetchRandomJoke() {
6 const response = await fetch(
7 "https://official-joke-api.appspot.com/random_joke",
8 );
10}
11
12const randomJoke = await fetchRandomJoke();
13const setup = randomJoke.setup;
14const punchline = randomJoke.punchline;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago