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=372&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 7883 results for "fetch"(1467ms)

nearsparkmain.tsx4 matches

@andybakUpdated 3 months ago
96
97 try {
98 console.log('Fetching image from:', imageUrl);
99 const response = await fetch(imageUrl);
100 if (!response.ok) {
101 throw new Error(`HTTP error! status: ${response.status}`);
144 let errorMessage = `Error processing image: ${error.message}. `;
145 if (error.message.includes('HTTP error')) {
146 errorMessage += 'The image could not be fetched from the provided URL. Please check if the URL is correct and accessible.';
147 } else if (error.message.includes('decode')) {
148 errorMessage += 'The image could not be decoded. Please ensure the URL points to a valid image file.';
149 } else if (error.message.includes('client error (Connect)')) {
150 errorMessage += 'There was a network error while trying to fetch the image. This might be due to network restrictions or the image server being unreachable.';
151 } else {
152 errorMessage += 'An unexpected error occurred while processing the image. Please try again or contact support if the issue persists.';

weatherAppmain.tsx5 matches

@yasinarfahtUpdated 3 months ago
10 useEffect(() => {
11 if (location.latitude && location.longitude) {
12 fetchWeather(location.latitude, location.longitude);
13 }
14 }, [location]);
15
16 const fetchWeather = async (lat, lon) => {
17 try {
18 const response = await fetch(
19 `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&current_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`,
20 );
22 setWeather(data);
23 } catch (error) {
24 console.error("Weather fetch failed", error);
25 }
26 };
44 const handleSearch = async () => {
45 try {
46 const geocodeResponse = await fetch(
47 `https://geocoding-api.open-meteo.com/v1/search?name=${
48 encodeURIComponent(searchQuery)

ios_AppStoreFetchermain.tsx30 matches

@arfanUpdated 3 months ago
104}
105button.paste-button,
106button.fetch-button {
107 background: var(--primary-color);
108 border: none;
209}
210
211/* Buttons (delete, refetch, etc.) */
212.button-row {
213 display: flex;
215}
216.delete-button,
217.refetch-button,
218.favorite-button {
219 background: none;
224}
225.delete-button:hover,
226.refetch-button:hover,
227.favorite-button:hover {
228 opacity: 0.8;
229}
230.delete-button { color: var(--danger-color); }
231.refetch-button { color: var(--primary-color); }
232.favorite-button { color: #ffc107; }
233
332 <meta charset="UTF-8" />
333 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
334 <title>App Store Info Fetcher</title>
335 <style>${css}</style>
336</head>
347 const url = new URL(request.url);
348 const { blob } = await import("https://esm.town/v/std/blob");
349 const KEY = "ios_AppStoreFetcher";
350
351 if (url.pathname === "/fetch-app-info") {
352 const appStoreUrl = url.searchParams.get("url");
353 if (!appStoreUrl) {
358 }
359 try {
360 const response = await fetch(appStoreUrl, {
361 headers: {
362 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
413 );
414 } catch (error) {
415 console.error("Error fetching app info:", error);
416 return new Response(
417 JSON.stringify({ error: "Failed to fetch app info: " + error.message }),
418 { status: 500, headers: { "Content-Type": "application/json" } },
419 );
446function App() {
447 const config = {
448 fetchEndpoint: "/fetch-app-info",
449 historyEndpoint: "/get-history",
450 saveEndpoint: "/save-history",
467
468 useEffect(() => {
469 fetchHistory();
470 }, []);
471
472 const fetchHistory = async () => {
473 try {
474 const response = await fetch(config.historyEndpoint);
475 if (response.ok) {
476 const history = await response.json();
478 }
479 } catch (err) {
480 console.error("Failed to fetch history:", err);
481 }
482 };
483
484 const fetchAppInfo = async (overrideUrl, force = false) => {
485 const useUrl = overrideUrl || url;
486 if (!useUrl) return;
496 setError(null);
497 try {
498 const res = await fetch(`${config.fetchEndpoint}?url=${encodeURIComponent(useUrl)}`);
499 if (!res.ok) throw new Error("Failed to fetch app info");
500 const data = await res.json();
501 if (data.error) throw new Error(data.error);
533 };
534
535 const refetchApp = (index) => {
536 const app = apps[index];
537 if (app?.link) fetchAppInfo(app.link, true);
538 };
539
612 if (draggedUrl) {
613 setUrl(draggedUrl);
614 fetchAppInfo(draggedUrl);
615 }
616 };
643
644 const save = async (newApps) => {
645 await fetch(config.saveEndpoint, {
646 method: "POST",
647 headers: { "Content-Type": "application/json" },
686 <div className="light maximize" />
687 </div>
688 <h1>App Store Info Fetcher ({totalApps})</h1>
689 <div className="actions">
690 <label className="import-button" title="Import JSON">
774 />
775 <button className="paste-button" onClick={handlePaste}>📋</button>
776 <button className="fetch-button" onClick={() => fetchAppInfo()} disabled={loading}>
777 {loading ? "Fetching..." : "Fetch"}
778 </button>
779 </div>
865 {app.favorite ? "★" : "☆"}
866 </button>
867 {/* Refetch */}
868 <button
869 className="refetch-button"
870 onClick={(evt) => {
871 evt.stopPropagation();
872 refetchApp(realIndex);
873 }}
874 title="Refetch this app"
875 >
876 ♻️

cerebras_codermain.tsx1 match

@kwt00Updated 3 months ago
187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({

lotterymahaGamemain.tsx10 matches

@funjoUpdated 3 months ago
24 e.preventDefault();
25 try {
26 const response = await fetch('/register', {
27 method: 'POST',
28 headers: { 'Content-Type': 'application/json' },
44 e.preventDefault();
45 try {
46 const response = await fetch('/login', {
47 method: 'POST',
48 headers: { 'Content-Type': 'application/json' },
57 setResult('Login successful!');
58
59 // Fetch withdrawal requests if admin
60 if (result.role === 'admin') {
61 fetchWithdrawalRequests();
62 }
63 } else {
69 };
70
71 const fetchWithdrawalRequests = async () => {
72 try {
73 const response = await fetch('/get-withdrawal-requests');
74 const result = await response.json();
75 if (result.success) {
77 }
78 } catch (error) {
79 setResult('Error fetching withdrawal requests');
80 }
81 };
88
89 try {
90 const response = await fetch('/submit-withdrawal', {
91 method: 'POST',
92 headers: { 'Content-Type': 'application/json' },
111 const handleWithdrawalApproval = async (requestId, action) => {
112 try {
113 const response = await fetch('/process-withdrawal', {
114 method: 'POST',
115 headers: { 'Content-Type': 'application/json' },
123 if (result.success) {
124 setResult(`Withdrawal ${action}ed successfully`);
125 fetchWithdrawalRequests();
126 } else {
127 setResult(result.message || 'Withdrawal processing failed');

blobStoragemain.tsx23 matches

@kamenxriderUpdated 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));

emailValHandlermain.tsx12 matches

@martinbowlingUpdated 3 months ago
138 lastRequestTime = Date.now();
139
140 console.log(`Fetching markdown for ${url}`);
141 console.log(`API Key present: ${!!apiKey}`);
142
143 const fetchUrl = `https://md.dhr.wtf/?url=${encodeURIComponent(url)}`;
144 console.log(`Fetch URL: ${fetchUrl}`);
145
146 const fetchOptions: RequestInit = {
147 method: "GET",
148 };
150 // Only add headers if API key is available
151 if (apiKey) {
152 fetchOptions.headers = {
153 "Authorization": `Bearer ${apiKey}`,
154 };
155 }
156
157 const response = await fetch(fetchUrl, fetchOptions);
158 console.log(`Response status: ${response.status}`);
159
165
166 const markdown = await response.text();
167 console.log(`Successfully fetched markdown for ${url}`);
168 console.log(`First 100 characters of markdown: ${markdown.substring(0, 100)}`);
169 markdownResults.push({ url, markdown });
170 } catch (error) {
171 console.error(`Error fetching markdown for ${url}:`, error);
172 markdownResults.push({ url, markdown: `Error fetching content: ${error.message}` });
173 }
174 }
179async function analyzeImage(imageAttachment, apiKey, transformedPrompt) {
180 try {
181 const response = await fetch("https://api.openai.com/v1/chat/completions", {
182 method: "POST",
183 headers: {
290 };
291
292 const response = await fetch(openaiUrl, {
293 method: "POST",
294 body: JSON.stringify(body),
418
419 // Send the request to OpenAI
420 const response = await fetch(openaiUrl, {
421 method: "POST",
422 body: JSON.stringify(body),

blob_adminmain.tsx23 matches

@sethblanchardUpdated 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));

jsoninvoicemain.tsx1 match

@alexweinUpdated 3 months ago
74});
75
76export default app.fetch;
77

bluesky_bot_templatemain.tsx6 matches

@alexweinUpdated 3 months ago
17}
18
19// Helper function to fetch SVG and convert to base64
20async function fetchSVGAsBase64(url: string): Promise<string> {
21 const response = await fetch(url);
22 if (!response.ok) {
23 throw new Error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);
24 }
25 const svgText = await response.text();
48
49 try {
50 // Fetch SVG from the specified URL
51 const svgDataUri = await fetchSVGAsBase64("https://alexwein-fabwbogglelike.web.val.run/?svg=1");
52
53 // Upload blob to Bluesky

fetchPaginatedData2 file matches

@nbbaierUpdated 1 week ago

FetchBasic1 file match

@fredmoonUpdated 1 week ago