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=652&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 10871 results for "fetch"(1490ms)

isMyWebsiteDownmain.tsx2 matches

@dtkav•Updated 3 months ago
17 start = performance.now();
18 try {
19 const res = await fetch(url, {
20 signal: AbortSignal.timeout(3000), // 3 second timeout
21 });
38 attempts++;
39 end = performance.now();
40 reason = `couldn't fetch: ${e}`;
41 ok = false;
42 console.log(`Attempt ${attempts}: Website down (${url}): ${reason} (${end - start}ms)`);

trackESMContentmain.tsx3 matches

@shouser•Updated 3 months ago
10const TABLE_NAME = `${KEY}_versions_v1`;
11
12async function fetchContent(url: string) {
13 const response = await fetch(url);
14 return await response.text();
15}
30
31 for (const url of URLS) {
32 const content = await fetchContent(url);
33 const latestVersion = await sqlite.execute(
34 `SELECT blob_key FROM ${TABLE_NAME} WHERE url = ? ORDER BY timestamp DESC LIMIT 1`,

getWeathermain.tsx2 matches

@charmaine•Updated 3 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6

caloriesmain.tsx2 matches

@AIWB•Updated 3 months ago
6
7function esmTown(url) {
8 return fetch(url, {
9 headers: {
10 "User-Agent":
15
16const app = new Hono();
17export default app.fetch;
18
19app.get("/", async (c) =>

aiMessengermain.tsx16 matches

@tesla6940•Updated 3 months ago
23
24 useEffect(() => {
25 async function fetchUser() {
26 try {
27 const response = await fetch("/authenticate");
28 const userData = await response.json();
29 setUser(userData);
30 fetchChatRooms(userData.id);
31 } catch (error) {
32 console.error("Authentication failed", error);
33 }
34 }
35 fetchUser();
36 }, []);
37
38 const fetchChatRooms = async (userId) => {
39 try {
40 const response = await fetch(`/get-rooms?userId=${userId}`);
41 const rooms = await response.json();
42 setChatRooms(rooms);
43 } catch (error) {
44 console.error("Failed to fetch chat rooms", error);
45 }
46 };
50
51 try {
52 const response = await fetch("/join-room", {
53 method: "POST",
54 headers: { "Content-Type": "application/json" },
68 setCurrentRoom(roomData);
69 setRoomError(null);
70 fetchRoomMessages(roomData.id);
71 } catch (error) {
72 console.error("Room joining failed", error);
75 };
76
77 const fetchRoomMessages = async (roomId) => {
78 try {
79 const response = await fetch(`/get-room-messages?roomId=${roomId}`);
80 const roomMessages = await response.json();
81 setMessages(roomMessages);
82 } catch (error) {
83 console.error("Failed to fetch room messages", error);
84 }
85 };
88 const newRoomCode = generateSecureRoomCode();
89 try {
90 const response = await fetch("/create-room", {
91 method: "POST",
92 headers: { "Content-Type": "application/json" },
100 setCurrentRoom(roomData);
101 setRoomCode("");
102 fetchChatRooms(user.id);
103 } catch (error) {
104 console.error("Room creation failed", error);
123
124 try {
125 const response = await fetch("/send-message", {
126 method: "POST",
127 headers: { "Content-Type": "application/json" },
302 onClick={() => {
303 setCurrentRoom(room);
304 fetchRoomMessages(room.id);
305 }}
306 style={{

selfassuredCoralPigmain.tsx16 matches

@tesla6940•Updated 3 months ago
23
24 useEffect(() => {
25 async function fetchUser() {
26 try {
27 const response = await fetch('/authenticate');
28 const userData = await response.json();
29 setUser(userData);
30 fetchChatRooms(userData.id);
31 } catch (error) {
32 console.error("Authentication failed", error);
33 }
34 }
35 fetchUser();
36 }, []);
37
38 const fetchChatRooms = async (userId) => {
39 try {
40 const response = await fetch(`/get-rooms?userId=${userId}`);
41 const rooms = await response.json();
42 setChatRooms(rooms);
43 } catch (error) {
44 console.error("Failed to fetch chat rooms", error);
45 }
46 };
50
51 try {
52 const response = await fetch('/join-room', {
53 method: 'POST',
54 headers: { 'Content-Type': 'application/json' },
68 setCurrentRoom(roomData);
69 setRoomError(null);
70 fetchRoomMessages(roomData.id);
71 } catch (error) {
72 console.error("Room joining failed", error);
75 };
76
77 const fetchRoomMessages = async (roomId) => {
78 try {
79 const response = await fetch(`/get-room-messages?roomId=${roomId}`);
80 const roomMessages = await response.json();
81 setMessages(roomMessages);
82 } catch (error) {
83 console.error("Failed to fetch room messages", error);
84 }
85 };
88 const newRoomCode = generateSecureRoomCode();
89 try {
90 const response = await fetch('/create-room', {
91 method: 'POST',
92 headers: { 'Content-Type': 'application/json' },
100 setCurrentRoom(roomData);
101 setRoomCode('');
102 fetchChatRooms(user.id);
103 } catch (error) {
104 console.error("Room creation failed", error);
123
124 try {
125 const response = await fetch('/send-message', {
126 method: 'POST',
127 headers: { 'Content-Type': 'application/json' },
293 onClick={() => {
294 setCurrentRoom(room);
295 fetchRoomMessages(room.id);
296 }}
297 style={{

prolificPinkGulltest.ts1 match

@chris_st•Updated 3 months ago
11const supabase = createClient(supabaseUrl, supabaseKey)
12
13// Disable prefetch as it is not supported for "Transaction" pool mode
14export const client = postgres(connectionString, { prepare: false })

filemain.tsx3 matches

@recklessreticence•Updated 3 months ago
162
163 const generateQRCode = async (id: string) => {
164 const response = await fetch(`https://recklessreticence-generateqr.web.val.run/?peer=${id}`);
165 // Wait for the full HTML text response.
166 const html = await response.text();
423});
424
425// self.addEventListener('fetch', (event) => {
426// event.respondWith(
427// caches.match(event.request).then((response) => {
428// return response || fetch(event.request);
429// })
430// );

spotifyRefreshTokenmain.tsx2 matches

@neverstew•Updated 3 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { querystring } from "https://esm.town/v/stevekrouse/querystring";
3
4export let spotifyRefreshToken = async ({ access_token, refresh_token, client_id, client_secret }) =>
5 fetchJSON("https://accounts.spotify.com/api/token", {
6 method: "POST",
7 body: await querystring({

blob_admin_migratedmain.tsx23 matches

@shouser•Updated 3 months ago
234 const [isDragging, setIsDragging] = useState(false);
235
236 const fetchBlobs = useCallback(async () => {
237 setLoading(true);
238 try {
239 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240 const data = await response.json();
241 setBlobs(data);
242 } catch (error) {
243 console.error("Error fetching blobs:", error);
244 } finally {
245 setLoading(false);
248
249 useEffect(() => {
250 fetchBlobs();
251 }, [fetchBlobs]);
252
253 const handleSearch = (e) => {
264 setBlobContentLoading(true);
265 try {
266 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267 const content = await response.text();
268 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269 setEditContent(content);
270 } catch (error) {
271 console.error("Error fetching blob content:", error);
272 } finally {
273 setBlobContentLoading(false);
278 const handleSave = async () => {
279 try {
280 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281 method: "PUT",
282 body: editContent,
290 const handleDelete = async (key) => {
291 try {
292 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293 setBlobs(blobs.filter(b => b.key !== key));
294 if (selectedBlob && selectedBlob.key === key) {
307 const key = `${searchPrefix}${file.name}`;
308 formData.append("key", encodeKey(key));
309 await fetch("/api/blob", { method: "POST", body: formData });
310 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311 setBlobs([newBlob, ...blobs]);
315 }
316 }
317 fetchBlobs();
318 };
319
329 try {
330 const fullKey = `${searchPrefix}${key}`;
331 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332 method: "PUT",
333 body: "",
344 const handleDownload = async (key) => {
345 try {
346 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347 const blob = await response.blob();
348 const url = window.URL.createObjectURL(blob);
363 if (newKey && newKey !== oldKey) {
364 try {
365 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366 const content = await response.blob();
367 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368 method: "PUT",
369 body: content,
370 });
371 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373 if (selectedBlob && selectedBlob.key === oldKey) {
383 const newKey = `__public/${key}`;
384 try {
385 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386 const content = await response.blob();
387 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388 method: "PUT",
389 body: content,
390 });
391 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393 if (selectedBlob && selectedBlob.key === key) {
402 const newKey = key.slice(9); // Remove "__public/" prefix
403 try {
404 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405 const content = await response.blob();
406 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407 method: "PUT",
408 body: content,
409 });
410 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412 if (selectedBlob && selectedBlob.key === key) {
826});
827
828export default lastlogin((request: Request) => app.fetch(request));

HN-fetch-call3 file matches

@ImGqb•Updated 3 hours ago
fetch HackerNews by API

FRAMERFetchBasic1 file match

@bresnik•Updated 2 days ago