stevensDemoindex.ts2 matches
135));
136137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;
stevensDemo.cursorrules5 matches
163```
1641655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169242243// Inject data to avoid extra round-trips
244const initialData = await fetchInitialData();
245const dataScript = `<script>
246window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
3003015. **API Design:**
302- `fetch` handler is the entry point for HTTP vals
303- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304- Properly handle CORS if needed for external access
stevensDemoApp.tsx17 matches
82const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
8384// Fetch images from backend instead of blob storage directly
85useEffect(() => {
86// Set default background color in case image doesn't load
89}
9091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
103});
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
129}, []);
130131const fetchMemories = useCallback(async () => {
132setLoading(true);
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
154}
155} catch (e) {
156console.error("Failed to fetch memories:", e);
157setError(e.message || "Failed to fetch memories.");
158} finally {
159setLoading(false);
162163useEffect(() => {
164fetchMemories();
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
188setNewMemoryTags("");
189setShowAddForm(false);
190await fetchMemories();
191} catch (e) {
192console.error("Failed to add memory:", e);
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
205throw new Error(`HTTP error! status: ${response.status}`);
206}
207await fetchMemories();
208} catch (e) {
209console.error("Failed to delete memory:", e);
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
240}
241setEditingMemory(null);
242await fetchMemories();
243} catch (e) {
244console.error("Failed to update memory:", e);
15const [error, setError] = useState<string | null>(null);
16
17// Fetch data on component mount
18useEffect(() => {
19const fetchData = async () => {
20try {
21setLoading(true);
22
23// Fetch categories
24const categoriesResponse = await fetch("/api/categories");
25if (!categoriesResponse.ok) {
26throw new Error("Failed to fetch categories");
27}
28const categoriesData = await categoriesResponse.json();
29setCategories(categoriesData);
30
31// Fetch vocabulary
32const vocabularyResponse = await fetch("/api/vocabulary");
33if (!vocabularyResponse.ok) {
34throw new Error("Failed to fetch vocabulary");
35}
36const vocabularyData = await vocabularyResponse.json();
39setLoading(false);
40} catch (err) {
41console.error("Error fetching data:", err);
42setError(err instanceof Error ? err.message : "An unknown error occurred");
43setLoading(false);
45};
46
47fetchData();
48}, []);
49
CrosswordQuizPage.tsx1 match
63
64// Update progress on the server (optional)
65fetch("/api/progress", {
66method: "POST",
67headers: {
16return c.json(categories);
17} catch (error) {
18console.error("Error fetching categories:", error);
19return c.json({ error: "Failed to fetch categories" }, 500);
20}
21});
32return c.json(vocabulary);
33} catch (error) {
34console.error("Error fetching vocabulary:", error);
35return c.json({ error: "Failed to fetch vocabulary" }, 500);
36}
37});
43return c.json(vocabulary);
44} catch (error) {
45console.error("Error fetching all vocabulary:", error);
46return c.json({ error: "Failed to fetch vocabulary" }, 500);
47}
48});
cosmoyepayment.ts2 matches
76} as ApiResponse<PaymentMethod[]>);
77} catch (error) {
78console.error("Error fetching payment methods:", error);
79return c.json({
80success: false,
81error: "Failed to fetch payment methods"
82} as ApiResponse<null>, 500);
83}
115} as ApiResponse<Order[]>);
116} catch (error) {
117console.error("Error fetching orders:", error);
118return c.json({
119success: false,
120error: "Failed to fetch orders"
121} as ApiResponse<null>, 500);
122}
150} as ApiResponse<Order>);
151} catch (error) {
152console.error("Error fetching order:", error);
153return c.json({
154success: false,
155error: "Failed to fetch order"
156} as ApiResponse<null>, 500);
157}