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);
untitled-936main.tsx1 match
1import ky from "https://esm.sh/ky";
23const response = await fetch("https://www.google.com?q=openai&hl=en&gl=us", {
4headers: {
5"User-Agent":
257addStatus(\`Loaded document '\${params.prefillDocSource || iqDocSource}' for new analysis.\`, 'info');
258setUIState('selection');
259fetchAndPopulateSuggestions(iqDocText.substring(0, 10000));
260} else {
261iqCustomTaskInput.value = params.initialTaskQuery || '';
285};
286287async function fetchAndPopulateSuggestions(docSample) {
288iqTasksListDiv.innerHTML = '<p><em>Fetching task suggestions...</em></p>';
289const formData = new FormData();
290formData.append('documentText', docSample);
291formData.append('inputSourceDescription', "For suggestions");
292try {
293const res = await fetch(window.location.pathname + '?action=suggestTasks&format=json', { method: 'POST', body: formData });
294const data = await res.json().catch(() => { throw new Error(\`Server returned non-JSON: \${res.status}\`); });
295(data.log || []).forEach(log => addStatus(\`[\${log.agent || 'S'}] \${typeof log.message === 'object' ? JSON.stringify(log.message) : esc(log.message)}\`, log.type));
297populateSuggestedTasks(data.suggestions && Object.keys(data.suggestions).length ? data.suggestions : { "General": [{task: "Summarize the document", is_high_priority: true}] });
298} catch (e) {
299addStatus(\`Could not fetch suggestions: \${e.message}\`, 'error');
300populateSuggestedTasks({ "Error": [{ task: "Could not load suggestions. Define task manually.", is_high_priority: true }] });
301}
419
420try {
421const res = await fetch(window.location.pathname + '?action=suggestTasks&format=json', { method: 'POST', body: formData });
422const data = await res.json().catch(() => { throw new Error(\`Server error: \${res.status}. Invalid JSON.\`); });
423(data.log || []).forEach(log => addStatus(\`[\${log.agent || 'Sys'}] \${typeof log.message === 'object' ? JSON.stringify(log.message) : esc(log.message)}\`, log.type === 'error' ? 'error' : 'info'));
455456try {
457const res = await fetch(window.location.pathname + '?format=json', { method: 'POST', body: formData });
458const data = await res.json().catch(() => { throw new Error(\`Server error: \${res.status}. Invalid JSON.\`); });
459(data.log || []).forEach(log => { if (log.type !== 'final' && log.type !== 'input') addStatus(\`[\${log.agent || 'Sys'}] \${typeof log.message === 'object' ? JSON.stringify(log.message) : esc(log.message)}\`, log.type === 'error' ? 'error' : 'info'); });
FetchBasicmain.tsx1 match
5859// Call Ticket Tailor Overview API
60const response = await fetch("https://api.tickettailor.com/v1/overview", {
61method: "GET",
62headers: {
cerebras_coderindex.ts1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
FetchBasicREADME.md2 matches
1# Framer Fetch: Basic
23A basic example of an API endpoint to use with Framer Fetch.
poor-randommain.tsx2 matches
1718try {
19const res = await fetch(url);
20const html = await res.text();
21const root = parse(html);
70} catch (err: any) {
71console.error("Error:", err);
72return new Response(JSON.stringify({ error: "Failed to fetch or parse HTML" }), {
73status: 500,
74headers: HEADERS,
336const apiCall = (endpoint, options = {}) => {
337if (!apiBase) return Promise.reject("API base not set");
338return fetch(`${apiBase}${endpoint}`, options);
339};
340436await getStatus(); // Initial check
437isConnected = true;
438list = await getList(); // Fetch initial list
439startPolling();
440render();
478}
479} catch(e) {
480console.error("Failed to fetch services", e);
481// Status poll will handle disconnect
482}
491492const startServicesPolling = () => {
493pollServices(); // Initial fetch
494if (!servicesInterval) {
495servicesInterval = setInterval(pollServices, 5000);
575app.get("/main.js", serve(js, "text/javascript"));
576577export default app.fetch;
YoutubeDownloaderindex.ts1 match
3536// This is the entry point for HTTP vals
37export default app.fetch;