observantGoldOctopusmain.tsx4 matches
1import { email } from "https://esm.town/v/std/email?v=9";
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
7);
9}
1011const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
1011const queryUrl = `https://steamcommunity.com/market/pricehistory/?appid=730&market_hash_name=${name}`;
12const res = await fetch(queryUrl, {
13headers: { "Cookie": Deno.env.get("steam_cookie") ?? "" },
14});
spagindex.html6 matches
230uploadButton.disabled = true;
231uploadButton.textContent = "Uploading...";
232const response = await fetch("/api/upload", {
233method: "POST",
234body,
250);
251252async function fetchUploads() {
253const response = await fetch("/api/list");
254const data = await response.json();
255return data.rows;
260previewAllButton.hidden = true;
261refreshButton.textContent = "Refreshing...";
262const uploads = await fetchUploads();
263renderUploads(uploads);
264refreshButton.textContent = "Refresh";
310previewContainer.innerHTML = "";
311try {
312fetch(`https://spag.cc/${upload.name}`).then(async (response) => {
313if (!response.ok) {
314const textElement = document.createElement("p");
394deleteButton.disabled = true;
395deleteButton.textContent = "Deleting...";
396const response = await fetch(
397`/api/delete`,
398{
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) {
838});
839840export default lastlogin((request: Request) => app.fetch(request));
exemplaryTanFireflymain.tsx5 matches
6465useEffect(() => {
66fetchContent();
67fetchHistory();
68}, []);
6970async function fetchContent() {
71const storedContent = await get(STORAGE_KEY);
72setContent(storedContent || "<h1>Edit Me!</h1>");
73}
7475async function fetchHistory() {
76const storedHistory = await get(HISTORY_KEY) || [];
77setHistory(storedHistory);
108await set(STORAGE_KEY, sanitizedHtml);
109await updateHistory(sanitizedHtml);
110await fetchHistory();
111setEditRequest("");
112} catch (err) {
FetchBasicREADME.md2 matches
1# Framer Fetch: Basic
23A basic example of an API endpoint to use with Framer Fetch.
Open-ToownieuseProjectFiles.ts4 matches
1import { useState, useEffect } from "https://esm.sh/react@18.2.0?dev";
2import { fetchProjectFiles } from "../utils/api.ts";
34interface UseProjectFilesProps {
1516/**
17* Custom hook to fetch and manage project files
18*/
19export function useProjectFiles({
38
39try {
40const filesData = await fetchProjectFiles({
41bearerToken,
42projectId,
51}
52} catch (err) {
53console.error("Error fetching project files:", err);
54setProjectFiles([]);
55setError(err instanceof Error ? err : new Error(String(err)));
Open-Toownietext-editor.ts1 match
135let type_: "file" | "http" | "script";
136if (path.includes("backend/index.ts")) type_ = "http";
137if (file_text?.includes("export default app.fetch")) type_ = "http";
138if ([".ts", ".tsx", ".js", ".jsx"].some(ext => path.endsWith(ext))) {
139type_ = "script";
Open-Toowniesystem_prompt.txt5 matches
71```
72735. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
74```ts
75const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
76```
77200
201// Inject data to avoid extra round-trips
202const initialData = await fetchInitialData();
203const dataScript = `<script>
204window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
2582595. **API Design:**
260- `fetch` handler is the entry point for HTTP vals
261- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
262- Properly handle CORS if needed for external access
Open-Toowniesend-message.ts3 matches
94}
9596// If there are selected files, fetch their content and add them to the messages
97if (selectedFiles && selectedFiles.length > 0) {
98const vt = new ValTown({ bearerToken });
114fileContents += `## File: ${filePath}\n\`\`\`\n${content}\n\`\`\`\n\n`;
115} catch (error) {
116console.error(`Error fetching file ${filePath}:`, error);
117fileContents += `## File: ${filePath}\nError: Could not fetch file content\n\n`;
118}
119}