9697try {
98console.log('Fetching image from:', imageUrl);
99const response = await fetch(imageUrl);
100if (!response.ok) {
101throw new Error(`HTTP error! status: ${response.status}`);
144let errorMessage = `Error processing image: ${error.message}. `;
145if (error.message.includes('HTTP error')) {
146errorMessage += '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')) {
148errorMessage += '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)')) {
150errorMessage += '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 {
152errorMessage += 'An unexpected error occurred while processing the image. Please try again or contact support if the issue persists.';
weatherAppmain.tsx5 matches
10useEffect(() => {
11if (location.latitude && location.longitude) {
12fetchWeather(location.latitude, location.longitude);
13}
14}, [location]);
1516const fetchWeather = async (lat, lon) => {
17try {
18const response = await fetch(
19`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`,
20);
22setWeather(data);
23} catch (error) {
24console.error("Weather fetch failed", error);
25}
26};
44const handleSearch = async () => {
45try {
46const geocodeResponse = await fetch(
47`https://geocoding-api.open-meteo.com/v1/search?name=${
48encodeURIComponent(searchQuery)
ios_AppStoreFetchermain.tsx30 matches
104}
105button.paste-button,
106button.fetch-button {
107background: var(--primary-color);
108border: none;
209}
210211/* Buttons (delete, refetch, etc.) */
212.button-row {
213display: flex;
215}
216.delete-button,
217.refetch-button,
218.favorite-button {
219background: none;
224}
225.delete-button:hover,
226.refetch-button:hover,
227.favorite-button:hover {
228opacity: 0.8;
229}
230.delete-button { color: var(--danger-color); }
231.refetch-button { color: var(--primary-color); }
232.favorite-button { color: #ffc107; }
233332<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>
347const url = new URL(request.url);
348const { blob } = await import("https://esm.town/v/std/blob");
349const KEY = "ios_AppStoreFetcher";
350351if (url.pathname === "/fetch-app-info") {
352const appStoreUrl = url.searchParams.get("url");
353if (!appStoreUrl) {
358}
359try {
360const response = await fetch(appStoreUrl, {
361headers: {
362"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
413);
414} catch (error) {
415console.error("Error fetching app info:", error);
416return new Response(
417JSON.stringify({ error: "Failed to fetch app info: " + error.message }),
418{ status: 500, headers: { "Content-Type": "application/json" } },
419);
446function App() {
447const config = {
448fetchEndpoint: "/fetch-app-info",
449historyEndpoint: "/get-history",
450saveEndpoint: "/save-history",
467468useEffect(() => {
469fetchHistory();
470}, []);
471472const fetchHistory = async () => {
473try {
474const response = await fetch(config.historyEndpoint);
475if (response.ok) {
476const history = await response.json();
478}
479} catch (err) {
480console.error("Failed to fetch history:", err);
481}
482};
483484const fetchAppInfo = async (overrideUrl, force = false) => {
485const useUrl = overrideUrl || url;
486if (!useUrl) return;
496setError(null);
497try {
498const res = await fetch(`${config.fetchEndpoint}?url=${encodeURIComponent(useUrl)}`);
499if (!res.ok) throw new Error("Failed to fetch app info");
500const data = await res.json();
501if (data.error) throw new Error(data.error);
533};
534535const refetchApp = (index) => {
536const app = apps[index];
537if (app?.link) fetchAppInfo(app.link, true);
538};
539612if (draggedUrl) {
613setUrl(draggedUrl);
614fetchAppInfo(draggedUrl);
615}
616};
643644const save = async (newApps) => {
645await fetch(config.saveEndpoint, {
646method: "POST",
647headers: { "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
869className="refetch-button"
870onClick={(evt) => {
871evt.stopPropagation();
872refetchApp(realIndex);
873}}
874title="Refetch this app"
875>
876♻️
cerebras_codermain.tsx1 match
187188try {
189const response = await fetch("/", {
190method: "POST",
191body: JSON.stringify({
lotterymahaGamemain.tsx10 matches
24e.preventDefault();
25try {
26const response = await fetch('/register', {
27method: 'POST',
28headers: { 'Content-Type': 'application/json' },
44e.preventDefault();
45try {
46const response = await fetch('/login', {
47method: 'POST',
48headers: { 'Content-Type': 'application/json' },
57setResult('Login successful!');
58
59// Fetch withdrawal requests if admin
60if (result.role === 'admin') {
61fetchWithdrawalRequests();
62}
63} else {
69};
7071const fetchWithdrawalRequests = async () => {
72try {
73const response = await fetch('/get-withdrawal-requests');
74const result = await response.json();
75if (result.success) {
77}
78} catch (error) {
79setResult('Error fetching withdrawal requests');
80}
81};
8889try {
90const response = await fetch('/submit-withdrawal', {
91method: 'POST',
92headers: { 'Content-Type': 'application/json' },
111const handleWithdrawalApproval = async (requestId, action) => {
112try {
113const response = await fetch('/process-withdrawal', {
114method: 'POST',
115headers: { 'Content-Type': 'application/json' },
123if (result.success) {
124setResult(`Withdrawal ${action}ed successfully`);
125fetchWithdrawalRequests();
126} else {
127setResult(result.message || 'Withdrawal processing failed');
blobStoragemain.tsx23 matches
234const [isDragging, setIsDragging] = useState(false);
235236const fetchBlobs = useCallback(async () => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
242} catch (error) {
243console.error("Error fetching blobs:", error);
244} finally {
245setLoading(false);
248249useEffect(() => {
250fetchBlobs();
251}, [fetchBlobs]);
252253const handleSearch = (e) => {
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269setEditContent(content);
270} catch (error) {
271console.error("Error fetching blob content:", error);
272} finally {
273setBlobContentLoading(false);
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
315}
316}
317fetchBlobs();
318};
319329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
826});
827828export default lastlogin((request: Request) => app.fetch(request));
emailValHandlermain.tsx12 matches
138lastRequestTime = Date.now();
139140console.log(`Fetching markdown for ${url}`);
141console.log(`API Key present: ${!!apiKey}`);
142143const fetchUrl = `https://md.dhr.wtf/?url=${encodeURIComponent(url)}`;
144console.log(`Fetch URL: ${fetchUrl}`);
145146const fetchOptions: RequestInit = {
147method: "GET",
148};
150// Only add headers if API key is available
151if (apiKey) {
152fetchOptions.headers = {
153"Authorization": `Bearer ${apiKey}`,
154};
155}
156157const response = await fetch(fetchUrl, fetchOptions);
158console.log(`Response status: ${response.status}`);
159165166const markdown = await response.text();
167console.log(`Successfully fetched markdown for ${url}`);
168console.log(`First 100 characters of markdown: ${markdown.substring(0, 100)}`);
169markdownResults.push({ url, markdown });
170} catch (error) {
171console.error(`Error fetching markdown for ${url}:`, error);
172markdownResults.push({ url, markdown: `Error fetching content: ${error.message}` });
173}
174}
179async function analyzeImage(imageAttachment, apiKey, transformedPrompt) {
180try {
181const response = await fetch("https://api.openai.com/v1/chat/completions", {
182method: "POST",
183headers: {
290};
291292const response = await fetch(openaiUrl, {
293method: "POST",
294body: JSON.stringify(body),
418419// Send the request to OpenAI
420const response = await fetch(openaiUrl, {
421method: "POST",
422body: JSON.stringify(body),
blob_adminmain.tsx23 matches
234const [isDragging, setIsDragging] = useState(false);
235236const fetchBlobs = useCallback(async () => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
242} catch (error) {
243console.error("Error fetching blobs:", error);
244} finally {
245setLoading(false);
248249useEffect(() => {
250fetchBlobs();
251}, [fetchBlobs]);
252253const handleSearch = (e) => {
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269setEditContent(content);
270} catch (error) {
271console.error("Error fetching blob content:", error);
272} finally {
273setBlobContentLoading(false);
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
315}
316}
317fetchBlobs();
318};
319329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
826});
827828export default lastlogin((request: Request) => app.fetch(request));
jsoninvoicemain.tsx1 match
74});
7576export default app.fetch;
77
bluesky_bot_templatemain.tsx6 matches
17}
1819// Helper function to fetch SVG and convert to base64
20async function fetchSVGAsBase64(url: string): Promise<string> {
21const response = await fetch(url);
22if (!response.ok) {
23throw new Error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);
24}
25const svgText = await response.text();
4849try {
50// Fetch SVG from the specified URL
51const svgDataUri = await fetchSVGAsBase64("https://alexwein-fabwbogglelike.web.val.run/?svg=1");
5253// Upload blob to Bluesky