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);
personalShopperindex.ts5 matches
296return c.json(location);
297} catch (error) {
298console.error("Location fetch error:", error);
299return c.json(
300{ error: "Failed to fetch location", details: error.message },
301500,
302);
507}
508} catch (error) {
509console.error("Error fetching preferred location:", error);
510// Continue without location data
511}
527app.get("/ui-kit/*", (c) => files.serveFile(c, c.req.path, import.meta.url));
528529export default app.fetch;
530531if (import.meta.main) {
532const port = parseInt(Deno.env.get("PORT") || "8080");
533console.log(`Server running on http://localhost:${port}`);
534Deno.serve({ port }, app.fetch);
535}
536
personalShopperLocationSearch.tsx2 matches
2223try {
24const response = await fetch(
25`/api/locations/search?zipCode=${encodeURIComponent(
26zipCode
45const handleSelectLocation = async (location: Location): Promise<void> => {
46try {
47const response = await fetch("/api/user/location", {
48method: "PUT",
49headers: { "Content-Type": "application/json" },
personalShopperNavbar.tsx1 match
6const handleLogout = async (): Promise<void> => {
7try {
8await fetch("/auth/logout", { method: "POST" });
9window.location.reload();
10} catch (error) {
personalShopperDashboard.tsx3 matches
23try {
24const [guidanceResponse, selectionsResponse] = await Promise.all([
25fetch("/api/guidance"),
26fetch("/api/selections"),
27]);
2844) {
45try {
46const response = await fetch(
47`/api/locations/${userData.preferredLocationId}`
48);
120121// Get the last 30 messages
122console.log("Fetching messages...");
123const messages = await getMessages();
124console.log("Messages fetched, count:", messages.length);
125126// Log all messages for debugging
166167// Get the last 30 messages in structured format
168console.log("Fetching messages...");
169const messages = await getMessages();
170console.log("Messages fetched, count:", messages.length);
171172// Generate AI response
reactHonoStarterindex.ts2 matches
21});
2223// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;
houseSearchSFscrapedHouses.tsx6 matches
1// This val creates a form to input a Zillow or Craigslist link, determines the link type,
2// calls the appropriate scraping API, and renders the results in a table.
3// It uses React for the UI, fetch for API calls, and basic string manipulation for link validation.
45/** @jsxImportSource https://esm.sh/react */
2021try {
22const response = await fetch("/scrape", {
23method: "POST",
24headers: { "Content-Type": "application/json" },
2728if (!response.ok) {
29throw new Error("Failed to fetch data");
30}
3133setResults(data);
34} catch (err) {
35setError("An error occurred while fetching the data.");
36} finally {
37setIsLoading(false);
102103try {
104const scrapeResponse = await fetch(`${scrapingEndpoint}${encodeURIComponent(link)}`);
105if (!scrapeResponse.ok) {
106throw new Error("Failed to scrape data");
109110// Calculate transit time
111const transitResponse = await fetch(
112`https://shapedlines-calculatetransitapi.web.val.run?address=${encodeURIComponent(scrapeResult.address)}`,
113);
910try {
11const response = await fetch(url);
12const html = await response.text();
13