16 lines
No EOL
511 B
JavaScript
16 lines
No EOL
511 B
JavaScript
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;
|
|
} |