untitled-2795main.tsx3 matches
1import axios from "axios";
2async function fetchUsers() {
3try {
4const response = await axios.get("https://jsonplaceholder.typicode.com/users");
7console.log(users);
8} catch (error) {
9console.error("Error fetching users:", error.message);
10}
11}
12fetchUsers();
endpointsget_vals_endpoints.tsx3 matches
1112// Get my vals using the authenticated /me/vals endpoint
13const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
14headers: {
15"Authorization": `Bearer ${apiKey}`,
22console.log("API Error response:", errorText);
23throw new Error(
24`Failed to fetch vals: ${valsResponse.status} ${valsResponse.statusText}. Response: ${errorText}`,
25);
26}
43try {
44// Use the files API to get the actual file structure
45const filesResponse = await fetch(
46`https://api.val.town/v2/vals/${val.id}/files?path=&recursive=true&limit=100`,
47{
3### status:
45- [x] fetch my vals
6- [x] loop through vals
7- [x] look at each val's file list to find endpoints.tsx
10- [ ] read each matching val's endpoints file
11- [ ] format output
12- [ ] fetch it from cloudflare
13- [ ] implement caching
14
57
58// Get location first
59const locationResponse = await fetch("/api/location");
60const locationData = await locationResponse.json();
61setLocation(locationData);
62
63// Then get weather data
64await fetchWeatherData(locationData.lat, locationData.lon);
65} catch (err) {
66setError("Failed to load weather data");
70};
7172const fetchWeatherData = async (lat: number, lon: number) => {
73const response = await fetch(`/api/weather?lat=${lat}&lon=${lon}`);
74const data = await response.json();
75
92
93if (coords.length === 2 && !isNaN(coords[0]) && !isNaN(coords[1])) {
94await fetchWeatherData(coords[0], coords[1]);
95setLocation({
96lat: coords[0],
103}
104} catch (err) {
105setError("Failed to fetch weather for this location");
106} finally {
107setLoading(false);
9495// Call Anthropic API
96const response = await fetch("https://api.anthropic.com/v1/messages", {
97method: "POST",
98headers: {
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { fetchWeatherApi } from "https://esm.sh/openmeteo";
45const app = new Hono();
29
30try {
31const responses = await fetchWeatherApi("https://api.open-meteo.com/v1/forecast", params);
32const response = responses[0];
33
81return c.json(processedData);
82} catch (error) {
83return c.json({ error: "Failed to fetch weather data", details: error.message }, 500);
84}
85});
90
91try {
92const response = await fetch(`http://ip-api.com/json/${ip}`);
93const data = await response.json();
94
186}
187188export default app.fetch;
stevensDemosendDailyBrief.ts1 match
135const lastSunday = today.startOf("week").minus({ days: 1 });
136137// Fetch relevant memories using the utility function
138const memories = await getRelevantMemories();
139
stevensDemoNotebookView.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);