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-1615App.js5 matches
82const [sortConfig, setSortConfig] = useState({ key: "name", direction: "ascending" });
8384// Fetch and process data
85useEffect(() => {
86const fetchData = async () => {
87setIsLoading(true);
88setError(null);
89try {
90const response = await fetch(JSON_URL);
91if (!response.ok) {
92throw new Error(`HTTP error! status: ${response.status}`);
117setModesList(["", ...uniqueModes]); // Add "All" option
118} catch (e) {
119console.error("Failed to fetch or process model data:", e);
120setError(e.message);
121} finally {
123}
124};
125fetchData();
126}, []);
127
OpenTownieuseProject.tsx5 matches
11const [error, setError] = useState(null);
1213const fetchData = async () => {
14try {
15const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
23};
2425const { project } = await fetch(projectEndpoint, { headers })
26.then(res => res.json());
27const { files } = await fetch(filesEndpoint, { headers })
28.then(res => res.json());
2940useEffect(() => {
41if (!projectId) return;
42fetchData();
43}, [projectId, branchId]);
4445return { data, loading, error, refetch: fetchData };
46}
47
OpenTownieuseProjects.tsx5 matches
10const [error, setError] = useState(null);
1112const fetchData = async () => {
13try {
14const res = await fetch(ENDPOINT, {
15headers: {
16"Authorization": "Bearer " + token,
18})
19const data = await res.json();
20console.log("useProjects fetchData", { res, data });
21if (!res.ok) {
22console.error(data);
3940useEffect(() => {
41fetchData();
42}, []);
4344return { data, loading, error, refetch: fetchData };
45}
46
19setError(null);
20try {
21const res = await fetch(ENDPOINT, {
22method: "POST",
23headers: {
16setData(null);
17setError(null);
18const res = await fetch(ENDPOINT, {
19method: "POST",
20headers: {
OpenTownieuseBranches.tsx4 matches
9const [loading, setLoading] = useState(true);
1011const fetchData = async () => {
12const endpoint = new URL(ENDPOINT, window.location.origin);
13endpoint.searchParams.append("projectId", projectId);
1415const res = await fetch(endpoint, {
16headers: {
17"Authorization": "Bearer " + token,
24useEffect(() => {
25if (!projectId) return;
26fetchData();
27}, [projectId]);
2829return { data, loading, refetch: fetchData };
30}
31
OpenTownieuseAuth.tsx1 match
15// replace all this with oauth when it's ready
16try {
17const res = await fetch("/api/user", {
18headers: {
19"Authorization": "Bearer " + valTownAPIKey,
OpenTownietext-editor.ts1 match
136let type_: "file" | "http" | "script";
137if (path.includes("backend/index.ts")) type_ = "http";
138if (file_text?.includes("export default app.fetch")) type_ = "http";
139if ([".ts", ".tsx", ".js", ".jsx"].some(ext => path.endsWith(ext))) {
140type_ = "script";
OpenTowniesystem_prompt.txt3 matches
233
234// Inject data to avoid extra round-trips
235const initialData = await fetchInitialData();
236const dataScript = `<script>
237window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
2802815. **API Design:**
282- `fetch` handler is the entry point for HTTP vals
283- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`