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);
onlyRuckusDropsmain.tsx8 matches
5const STORAGE_KEY = "kerehaklu_snapshot";
67async function fetchWebpage(url: string): Promise<string> {
8const response = await fetch(url, {
9headers: {
10"User-Agent":
1415if (!response.ok) {
16throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
17}
1850}
5152async function fetchData(): Promise<any> {
53const response = await fetch(
54"https://api.dm2buy.com/v3/product/store/2a6975fbe4b4b5097f969318609fab84/collectionv2?page=1&limit=20&source=web",
55{
61);
62if (!response.ok) {
63throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
64}
65return response.json();
83export default async function(interval: Interval) {
84try {
85const data = await fetchData();
86// const currentContent = await fetchWebpage(URL);
87const currentHash = createJSONSnapshot(data);
88const previousHash = await getPreviousSnapshot();
test-multiembedt.tsx3 matches
9export default async function(req: Request): Promise<Response> {
10const API_URL: string = "https://api.val.town";
11async function proxiedFetch(input: string | URL, requestInit?: RequestInit) {
12let query = new URLSearchParams({
13url: input.toString(),
14});
15return fetch(`${API_URL}/v1/fetch?${query}`, {
16...requestInit,
17// @ts-ignore
24});
25}
26return new Response(await (await proxiedFetch(new URL(req.url).searchParams.get("url"))).body);
27}
untitled-5703index.ts2 matches
36let html = await readFile("/frontend/index.html", import.meta.url);
37
38// Fetch initial data
39const jobs = await getAllJobs();
40const messages = await getMessages(20);
118119// Export the app
120export default app.fetch;
untitled-5703index.js15 matches
132133// Jobs functionality
134async function fetchJobs() {
135try {
136const response = await fetch('/api/jobs');
137if (!response.ok) throw new Error('Failed to fetch jobs');
138
139state.jobs = await response.json();
140renderJobs();
141} catch (error) {
142console.error('Error fetching jobs:', error);
143elements.jobsList.innerHTML = '<p class="text-red-500">Error loading jobs. Please try again later.</p>';
144}
188elements.submitJobButton.textContent = 'Posting...';
189
190const response = await fetch('/api/jobs', {
191method: 'POST',
192headers: {
234}
235236async function fetchMessages() {
237try {
238const response = await fetch('/api/messages');
239if (!response.ok) throw new Error('Failed to fetch messages');
240
241const messages = await response.json();
249}
250} catch (error) {
251console.error('Error fetching messages:', error);
252}
253}
292};
293
294const response = await fetch('/api/messages', {
295method: 'POST',
296headers: {
305elements.chatInput.value = '';
306
307// Fetch latest messages
308await fetchMessages();
309} catch (error) {
310console.error('Error sending message:', error);
330// Setup polling for chat messages
331function setupMessagePolling() {
332// Initial fetch
333fetchMessages();
334
335// Poll every 5 seconds
336state.messagePollingInterval = setInterval(fetchMessages, 5000);
337}
338
Mercurymercury.ts4 matches
44
45try {
46const response = await fetch(url, options);
47
48console.log(`Response status: ${response.status}`);
72async getAccounts(): Promise<MercuryAccount[]> {
73try {
74console.log('Fetching accounts from Mercury API');
75// Try the documented endpoint structure first
76const response = await this.request<{ accounts: MercuryAccount[] }>('/accounts');
102async getAccount(accountId: string): Promise<MercuryAccount> {
103try {
104console.log(`Fetching account ${accountId}`);
105const response = await this.request<{ account: MercuryAccount } | MercuryAccount>(`/accounts/${accountId}`);
106
127): Promise<MercuryPaginatedResponse<MercuryTransaction>> {
128try {
129console.log(`Fetching transactions for account ${accountId}, limit: ${limit}`);
130
131// Try different endpoint formats to handle potential API variations
38return formatAccountBalances(accounts);
39} catch (error) {
40console.error('Error fetching balances:', error);
41return formatErrorMessage('Failed to fetch account balances. Please try again later.');
42}
43}
51
52// Get all accounts first
53console.log('Fetching accounts...');
54const accounts = await mercury.getAccounts();
55console.log('Accounts fetched:', JSON.stringify(accounts));
56
57if (accounts.length === 0) {
69limit = Math.min(20, Math.max(1, Number(args[0])));
70}
71console.log(`Fetching ${limit} transactions...`);
72
73try {
91cause: error.cause
92});
93return formatErrorMessage(`Failed to fetch transactions: ${error.message}`);
94}
95}
beeAifrontend.html2 matches
378try {
379// Send message to API
380const response = await fetch('/api/chat', {
381method: 'POST',
382headers: {
444try {
445// Send request to generate image
446const response = await fetch('/api/generate-image', {
447method: 'POST',
448headers: {
94} as ChatEvent));
95} catch (error) {
96console.error("Error fetching message history:", error);
97}
98206return c.json(messages);
207} catch (error) {
208console.error("Error fetching messages:", error);
209return c.json({ error: "Failed to fetch messages" }, 500);
210}
211});
248249// This is the entry point for HTTP vals
250export default app.fetch;