// app/utils/api.ts export interface TimeSeriesEntry { time: string; value: number; } export interface TimeSeriesResponse { consumption: TimeSeriesEntry[]; generation: TimeSeriesEntry[]; } export async function fetchPowerTimeseries( site: string, start: string, end: string ): Promise { // <-- Change here const params = new URLSearchParams({ site, start, end }); const res = await fetch(`http://localhost:8000/power-timeseries?${params.toString()}`); if (!res.ok) { throw new Error(`Failed to fetch data: ${res.status}`); } const json = await res.json(); console.log(`🔍 API response from /power-timeseries?${params.toString()}:`, json); // ✅ log here return json; // <-- This is a single object, not an array }