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=477&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 8210 results for "fetch"(2512ms)

cors_examplemain.tsx1 match

@stevekrouse•Updated 5 months ago
9 async function request(url, options) {
10 try {
11 const response = await fetch(url, options);
12 const status = response.status;
13 const data = await response.text();

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,

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago