a8b48747537_index.ts2 matches
135));
136137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;
a8b48747537_.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
135const lastSunday = today.startOf("week").minus({ days: 1 });
136137// Fetch relevant memories using the utility function
138const memories = await getRelevantMemories();
139
a8b48747537_NotebookView.tsx12 matches
67const [currentPage, setCurrentPage] = useState(1);
6869const fetchMemories = useCallback(async () => {
70setLoading(true);
71setError(null);
72try {
73const response = await fetch(API_BASE);
74if (!response.ok) {
75throw new Error(`HTTP error! status: ${response.status}`);
78setMemories(data);
79} catch (e) {
80console.error("Failed to fetch memories:", e);
81setError(e.message || "Failed to fetch memories.");
82} finally {
83setLoading(false);
8687useEffect(() => {
88fetchMemories();
89}, [fetchMemories]);
9091const handleAddMemory = async (e: React.FormEvent) => {
100101try {
102const response = await fetch(API_BASE, {
103method: "POST",
104headers: { "Content-Type": "application/json" },
112setNewMemoryTags("");
113setShowAddForm(false);
114await fetchMemories();
115} catch (e) {
116console.error("Failed to add memory:", e);
123124try {
125const response = await fetch(`${API_BASE}/${id}`, {
126method: "DELETE",
127});
129throw new Error(`HTTP error! status: ${response.status}`);
130}
131await fetchMemories();
132} catch (e) {
133console.error("Failed to delete memory:", e);
155156try {
157const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
158method: "PUT",
159headers: { "Content-Type": "application/json" },
164}
165setEditingMemory(null);
166await fetchMemories();
167} catch (e) {
168console.error("Failed to update memory:", e);
a8b48747537_App.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);
resume-parserindex.ts1 match
6162// This is the entry point for HTTP vals
63export default app.fetch
lightweightindex.ts2 matches
99});
100101// Export the app's fetch handler as the default export for Val Town's HTTP trigger
102export default app.fetch;
MaxCareViz2index.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;
sqliteAdminDashboardmain.tsx13 matches
2021useEffect(() => {
22fetchTables();
23}, []);
2425const fetchTables = async () => {
26try {
27const response = await fetch("/tables");
28const data = await response.json();
29setTables(data);
30} catch (err) {
31setError("Failed to fetch tables");
32}
33};
3435const fetchTableData = async (tableName) => {
36try {
37const dataResponse = await fetch(`/table/${tableName}`);
38const data = await dataResponse.json();
39setTableData(data);
4041const schemaResponse = await fetch(`/schema/${tableName}`);
42const schema = await schemaResponse.json();
43setTableSchema(schema);
51setNewRow(emptyRow);
52} catch (err) {
53setError(`Failed to fetch data for table ${tableName}`);
54}
55};
61const handleSave = async (index) => {
62try {
63const response = await fetch(`/update/${selectedTable}`, {
64method: "POST",
65headers: {
72}
73setEditingRow(null);
74await fetchTableData(selectedTable);
75} catch (err) {
76setError(`Failed to update row: ${err.message}`);
90const handleAddRow = async () => {
91try {
92const response = await fetch(`/insert/${selectedTable}`, {
93method: "POST",
94headers: {
100throw new Error("Failed to add new row");
101}
102await fetchTableData(selectedTable);
103// Reset newRow to empty values
104const emptyRow = Object.keys(newRow).reduce((acc, key) => {
120<li
121key={table}
122onClick={() => fetchTableData(table)}
123className={selectedTable === table ? "active" : ""}
124>
templateTwitterAlertmain.tsx1 match
19: Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
2021// Fetch and log tweets
22const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23console.log("Response from socialDataSearch:", response);