feat: add minimal chart to display API data with hardcoded parameters
This commit is contained in:
parent
e71a0d9602
commit
8289d23cf9
4 changed files with 70 additions and 1 deletions
16
server/frontend/public/assets/js/api.js
Normal file
16
server/frontend/public/assets/js/api.js
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue