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=471&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 8149 results for "fetch"(1130ms)

blueskyPostButtonmain.tsx1 match

@lukedenton•Updated 5 months ago
10 const postToBluesky = async () => {
11 try {
12 const response = await fetch("/post-bluesky", {
13 method: "POST",
14 headers: {

curiousCyanWalrusmain.tsx4 matches

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

ThankYouNoteGeneratormain.tsx2 matches

@prashamtrivedi•Updated 5 months ago
70 setError("");
71 try {
72 const response = await fetch("/generate", {
73 method: "POST",
74 headers: { "Content-Type": "application/json" },
197 onClick={async () => {
198 try {
199 const response = await fetch(`/update/${noteId}`, {
200 method: "POST",
201 headers: { "Content-Type": "application/json" },

rssSummarizermain.tsx3 matches

@jamiedubs•Updated 5 months ago
20 setError(null);
21 try {
22 const response = await fetch("/run-glif", {
23 method: "POST",
24 headers: { "Content-Type": "application/json" },
32 }
33 } catch (error) {
34 console.error("Error fetching results:", error);
35 setError("Failed to fetch results. Please try again.");
36 }
37 setLoading(false);

runGlifmain.tsx1 match

@jamiedubs•Updated 5 months ago
25 };
26
27 const res = await fetch(`https://simple-api.glif.app`, {
28 method: "POST",
29 body: JSON.stringify(body),

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

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago