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/$1?q=fetch&page=1005&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 15630 results for "fetch"(8626ms)

email_capture_system_2routes.ts1 match

@prashamtrivedi•Updated 3 months ago
285});
286
287export default api.fetch;

email_capture_system_2index.ts1 match

@prashamtrivedi•Updated 3 months ago
54});
55
56export default app.fetch;
57

photosmain.tsx2 matches

@Learn•Updated 3 months ago
32 // Initialize with demo data
33 useEffect(() => {
34 // Simulate API fetch
35 setLoading(true);
36 setTimeout(() => {
250 // View user profile
251 const viewProfile = (userId) => {
252 // In a real app, fetch the user profile
253 // For demo, use current user's profile if it's their profile
254 if (userId === currentUser.id) {

dailySlackRoundupmain.tsx2 matches

@devbratpandey•Updated 3 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { getDayName } from "https://esm.town/v/stevekrouse/getDayName?v=2";
3import process from "node:process";
4
5export const dailySlackRoundup = (async () => {
6 const res = await fetch(process.env.BRAINBOT_WEBHOOK_URL, {
7 method: "POST",
8 body: JSON.stringify({

tangledRSSmain.tsx7 matches

@hrbrmstr•Updated 3 months ago
9 try {
10 // Resolve handle to DID
11 const handleResolveResponse = await fetch(
12 `https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=${handle}`,
13 );
14 const { did } = await handleResolveResponse.json();
15
16 // Fetch DID document
17 const didDocResponse = await fetch(`https://plc.directory/${did}`);
18 const didDoc = await didDocResponse.json();
19 const serviceEndpoint = didDoc.service[0].serviceEndpoint;
20
21 // Fetch all records
22 const allRecords = await fetchAllRecords(serviceEndpoint, did);
23
24 // Generate RSS feed
35}
36
37async function fetchAllRecords(serviceEndpoint: string, did: string): Promise<any[]> {
38 const allRecords: any[] = [];
39 let cursor = "";
46 if (cursor) url.searchParams.set("cursor", cursor);
47
48 const response = await fetch(url.toString());
49 const data = await response.json();
50

FixItWandusers.ts1 match

@wolf•Updated 3 months ago
38 .where(eq(usersTable.id, id));
39
40 // Fetch and return the updated user
41 return getUserById(id);
42}

jamzmain.tsx20 matches

@all•Updated 3 months ago
314function App() {
315 const [songs, setSongs] = React.useState<Song[]>([]);
316 const [sortBy, setSortBy] = React.useState<"date" | "title">("date"); // Default sort should match initial fetch if possible
317 const [selectedTag, setSelectedTag] = React.useState<string>("");
318 const [isLoading, setIsLoading] = React.useState(true);
321
322 // Using useCallback to stabilize the function reference
323 const fetchSongs = React.useCallback(async () => {
324 setError(""); // Clear previous errors before fetching
325 // Keep isLoading true if it was already true (initial load)
326 // Don't set it to true on subsequent fetches unless desired (e.g., manual refresh button)
327 try {
328 const response = await fetch("/api/songs");
329 if (!response.ok) {
330 const errorText = await response.text(); // Try to get error text
331 throw new Error(`Failed to fetch songs: ${response.status} ${errorText || response.statusText}`);
332 }
333 const data = await response.json();
339 setSongs(data as Song[]);
340 } catch (err) {
341 console.error("Fetch error:", err);
342 setError(`Failed to load songs. ${err.message || "Please try again later."}`);
343 // Consider clearing songs or leaving stale data based on desired UX
344 // setSongs([]); // Optional: Clear songs on error
345 } finally {
346 setIsLoading(false); // Always set loading to false after fetch attempt
347 }
348 }, []); // Empty dependency array: function created once
350 React.useEffect(() => {
351 setIsLoading(true); // Set loading true when the component mounts
352 fetchSongs();
353 }, [fetchSongs]); // Run effect when fetchSongs changes (which is only on mount)
354
355 const handleAdd = async (songData: Omit<Song, "id" | "created_at">) => {
363 };
364 try {
365 const response = await fetch("/api/songs", {
366 method: "POST",
367 headers: { "Content-Type": "application/json" },
372 throw new Error(`Failed to add song: ${response.status} ${errorText || response.statusText}`);
373 }
374 await fetchSongs(); // Refetch to update the list
375 } catch (err) {
376 console.error("Add error:", err);
400
401 try {
402 const response = await fetch(`/api/songs/${song.id}`, {
403 method: "PUT",
404 headers: { "Content-Type": "application/json" },
410 throw new Error(`Failed to update song: ${response.status} ${errorText || response.statusText}`);
411 }
412 // Optional: Refetch if server might modify data (e.g., updated_at, though not used here)
413 // await fetchSongs();
414 // If optimistic update is enough, no fetch needed here.
415 } catch (err) {
416 console.error("Edit error:", err);
428
429 try {
430 const response = await fetch(`/api/songs/${id}`, {
431 method: "DELETE",
432 });
435 throw new Error(`Failed to delete song: ${response.status} ${errorText || response.statusText}`);
436 }
437 // No fetch needed after successful delete with optimistic update
438 } catch (err) {
439 console.error("Delete error:", err);
464
465 // Sort (Client-side sorting is kept)
466 // Note: The initial fetch order from the original server was `position, created_at DESC`.
467 // Client-side sort overrides this. If you want initial load to match server,
468 // set default `sortBy` state based on that, or remove client sort initially.
594 {/* Songs Display Area */}
595 <main className="songs-area">
596 {isLoading && songs.length > 0 && ( // Show subtle loading indicator when refetching
597 <div className="loading-inline">
598 <span className="material-icons loading">sync</span> Refreshing...

Joaldamain.tsx7 matches

@GideonEsq•Updated 3 months ago
305
306 useEffect(() => {
307 fetchProducts();
308 }, []);
309
310 async function fetchProducts() {
311 const response = await fetch("/products");
312 const data = await response.json();
313 setProducts(data);
328 if (pendingAction.type === "delete") {
329 const productId = pendingAction.data as number;
330 fetch(`/delete-product/${productId}`, { method: "DELETE" })
331 .then(async (response) => {
332 if (response.ok) {
333 await fetchProducts();
334 setView("home");
335 alert("Product deleted successfully!");
338 } else if (pendingAction.type === "add") {
339 const product = pendingAction.data as Product;
340 fetch("/add-product", {
341 method: "POST",
342 headers: { "Content-Type": "application/json" },
345 if (response.ok) {
346 alert("Product added successfully!");
347 fetchProducts();
348 setView("home");
349 }

bskySoloLikesmain.tsx4 matches

@alexwein•Updated 3 months ago
12 url.searchParams.append("cursor", cursor);
13 }
14 const response = await fetch(url.toString());
15 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
16 return await response.json();
18
19async function getLikes(uri: string): Promise<any> {
20 const response = await fetch(`${BASE_URL}/app.bsky.feed.getLikes?uri=${uri}`);
21 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
22 return await response.json();
31
32 if (!feed.cursor) {
33 break; // No more posts to fetch
34 }
35
42}
43
44// Trim excess posts if we fetched more than 500
45if (allPosts.length > 500) {
46 allPosts.length = 500;

simpleLogoGeneratormain.tsx2 matches

@dcm31•Updated 3 months ago
119
120 // Store SVG blob
121 await fetch('https://api.val.town/v1/blobs', {
122 method: 'POST',
123 headers: {
133
134 // Store metadata blob
135 await fetch('https://api.val.town/v1/blobs', {
136 method: 'POST',
137 headers: {

manual-fetcher

@miz•Updated 2 days ago

fake-https1 file match

@blazemcworld•Updated 1 week ago
simple proxy to fetch http urls using https