113
114 useEffect(() => {
115 fetchSubscriptions();
116 }, []);
117
118 const fetchSubscriptions = async () => {
119 try {
120 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
128 setSubscriptions(result.rows);
129 } catch (error) {
130 console.error("Error fetching subscriptions:", error);
131 }
132 };
151 ]);
152
153 fetchSubscriptions();
154 } catch (error) {
155 console.error("Error adding subscription:", error);
20
21 try {
22 const response = await fetch("/chat", {
23 method: "POST",
24 headers: { "Content-Type": "application/json" },
20
21 try {
22 const response = await fetch("/chat", {
23 method: "POST",
24 headers: { "Content-Type": "application/json" },
234
235 try {
236 const response = await fetch("/", {
237 method: "POST",
238 body: JSON.stringify({
187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({
17 setIsLoading(true);
18 try {
19 const response = await fetch('/extract', {
20 method: 'POST',
21 body: JSON.stringify({ text })
133})
134
135export default app.fetch;
48async function uploadImage(agent: AtpAgent, imageUrl: string) {
49 try {
50 // Fetch the image
51 const response = await fetch(imageUrl);
52 if (!response.ok) {
53 console.error(`Failed to fetch image: ${imageUrl}`);
54 return null;
55 }
187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({
218 });
219 } catch (error) {
220 console.error("Error fetching messages:", error);
221 return new Response(
222 JSON.stringify({ error: "Failed to fetch messages" }),
223 { status: 500 },
224 );
379 const loadMessages = async () => {
380 try {
381 const response = await fetch("/messages");
382 if (!response.ok) {
383 throw new Error("Failed to fetch messages");
384 }
385 const data = await response.json();
386 setMessages(data);
387 } catch (error) {
388 console.error("Error fetching messages:", error);
389 setMessages([
390 {
406
407 try {
408 const response = await fetch("/chat", {
409 method: "POST",
410 headers: { "Content-Type": "application/json" },