cerebras_codermain.tsx1 match
182183try {
184const response = await fetch("/", {
185method: "POST",
186body: JSON.stringify({
ValTown-Package-Trackerindex.html2 matches
151async function loadDevices() {
152try {
153const response = await fetch('/api/devices');
154const devices = await response.json();
155
177const url = deviceId ? `/api/locations?deviceId=${deviceId}` : '/api/locations';
178
179const response = await fetch(url);
180locations = await response.json();
181
ValTown-Package-Trackerindex.ts11 matches
188// API endpoint to get location history
189app.get("/api/locations", async (c) => {
190console.log("[API] Fetching location history");
191
192try {
195console.log(`[API] Filtering locations by device ID: ${deviceId}`);
196} else {
197console.log("[API] Fetching all locations (no device filter)");
198}
199const { rows } = await getLocationHistory(deviceId);
208209} catch (error) {
210console.error("[API] Error fetching location history:", error);
211return c.json({
212error: "Database error",
213details: "Failed to fetch location history",
214message: error.message
215}, 500);
221try {
222const idParam = c.req.param("id");
223console.log(`[API] Fetching location with ID: ${idParam}`);
224
225const id = parseInt(idParam);
244return c.json(location);
245} catch (error) {
246console.error(`[API] Error fetching location:`, error);
247return c.json({
248error: "Database error",
249details: "Failed to fetch location data",
250message: error.message
251}, 500);
255// API endpoint to get list of devices
256app.get("/api/devices", async (c) => {
257console.log("[API] Fetching device list");
258
259try {
262return c.json(devices.rows);
263} catch (error) {
264console.error("[API] Error fetching devices:", error);
265return c.json({
266error: "Database error",
267details: "Failed to fetch device list",
268message: error.message
269}, 500);
272273// Export the Hono app for HTTP vals
274export default app.fetch;
TownieuseProject.tsx5 matches
9const [error, setError] = useState(null);
1011const fetchData = async () => {
12try {
13const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
17if (branchId) filesEndpoint.searchParams.append("branchId", branchId);
1819const { project } = await fetch(projectEndpoint)
20.then(res => res.json());
21const { files } = await fetch(filesEndpoint)
22.then(res => res.json());
2334useEffect(() => {
35if (!projectId) return;
36fetchData();
37}, [projectId, branchId]);
3839return { data, loading, error, refetch: fetchData };
40}
41
TownieuseProjects.tsx4 matches
8const [error, setError] = useState(null);
910const fetchData = async () => {
11try {
12const res = await fetch(ENDPOINT)
13const data = await res.json();
14if (!res.ok) {
3233useEffect(() => {
34fetchData();
35}, []);
3637return { data, loading, error, refetch: fetchData };
38}
39
TownieuseCreateProject.tsx1 match
16setError(null);
17try {
18const res = await fetch(ENDPOINT, {
19method: "POST",
20headers: {
TownieuseCreateBranch.tsx1 match
14setData(null);
15setError(null);
16const res = await fetch(ENDPOINT, {
17method: "POST",
18body: JSON.stringify({
TownieuseBranches.tsx4 matches
7const [loading, setLoading] = useState(true);
89const fetchData = async () => {
10const endpoint = new URL(ENDPOINT, window.location.origin);
11endpoint.searchParams.append("projectId", projectId);
1213const res = await fetch(endpoint)
14.then(res => res.json());
15setData(res.branches); // todo error handling
19useEffect(() => {
20if (!projectId) return;
21fetchData();
22}, [projectId]);
2324return { data, loading, refetch: fetchData };
25}
26
47<!--
4849- [x] refetch project data on create/etc
50- [x] Loading favicon
51- [x] Ensure main branch is default selected
Townietext-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";