feat: add minimal chart to display API data with hardcoded parameters

This commit is contained in:
Alexis Fourmaux 2026-05-11 23:17:43 +02:00
parent e71a0d9602
commit 8289d23cf9
4 changed files with 70 additions and 1 deletions

View file

@ -0,0 +1,16 @@
const API_BASE = 'http://192.168.1.195:8000'
const DEV_EUI = '0586fe41112d83d9';
async function fetchConsumption({ start, end, granularity }) {
const params = new URLSearchParams({ start, end, granularity });
const url = `${API_BASE}/readings/${DEV_EUI}?${params}`;
const result = await fetch(url);
if (!result.ok) {
const err = await result.json().catch(() => ({}));
throw new Error(err.detail || `Erreur HTTP ${result.status}`);
}
const raw = await result.json();
return raw.points;
}