32 return;
33 }
34 branches.refetch();
35 if (res?.branch?.id) {
36 navigate(`/chat/${projectId}/branch/${res.branch.id}`);
154 let currentIndex = 0;
155
156 // Fetch data
157 try {
158 const response = await fetch('/data.json');
159 const data = await response.json();
160 cards = data.redFlags;
163 updateCard();
164 } catch (error) {
165 console.error('Error fetching flashcards:', error);
166 cardTitle.textContent = 'Error loading cards';
167 cardDescription.textContent = 'Please try refreshing the page.';
24app.get("/frontend/*", (c) => serveFile(c.req.path, import.meta.url));
25
26export default app.fetch;
37## Future Improvements
38
39- Integrate with Luma API to fetch real events
40- Add filtering and search capabilities
41- Implement calendar view toggle (list/grid/month view)
362});
363
364// Export the fetch handler for HTTP val
365export default app.fetch;
30## Future Improvements
31
32- Integrate with Luma API to fetch real events
33- Add filtering and search capabilities
34- Implement calendar view toggle (list/grid/month view)
11
12 try {
13 const response = await fetch("/messages", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },
59});
60
61// HTTP vals expect an exported "fetch handler"
62// This is how you "run the server" in Val Town with Hono
63export default app.fetch;
9 const [messages, setMessages] = React.useState(initialMessages);
10
11 const fetchMessages = async () => {
12 try {
13 const response = await fetch("/messages");
14 const data = await response.json();
15 setMessages(data.reverse());
16 } catch (error) {
17 console.error("Failed to fetch messages", error);
18 }
19 };
23 <h1>💬 Message Board!</h1>
24 <MessageList messages={messages} />
25 <MessageInput onSubmit={fetchMessages} />
26 {thisProjectURL
27 ? (
1const baseUrl = "https://api.neynar.com/v2/farcaster/";
2
3export async function fetchNeynarGet(path: string) {
4 const res = await fetch(baseUrl + path, {
5 method: "GET",
6 headers: {
14}
15
16export function fetchUser(username: string) {
17 return fetchNeynarGet(`user/by_username?username=${username}`).then(r => r.user);
18}
19export function fetchUsersById(fids: string) {
20 return fetchNeynarGet(`user/bulk?fids=${fids}`).then(r => r.users);
21}
22
23export function fetchUserFeed(fid: number) {
24 return fetchNeynarGet(
25 `feed?feed_type=filter&filter_type=fids&fids=${fid}&with_recasts=false&with_replies=false&limit=100&cursor=`,
26 ).then(r => r.casts);
27}
28
29export function fetchChannel(channelId: string) {
30 return fetchNeynarGet(`channel?id=${channelId}`).then(r => r.channel);
31}
32
33export function fetchChannelFeed(channelId: string) {
34 return fetchNeynarGet(
35 `feed/channels?channel_ids=${channelId}&with_recasts=false&limit=100`,
36 ).then(r => r.casts);
37}
38
39export function fetchChannelsFeed(channelIds: array) {
40 return fetchNeynarGet(
41 `feed/channels?channel_ids=${channelIds.join(",")}&with_recasts=false&limit=100`,
42 ).then(r => r.casts);