Trying to get a grasp from frontend

This commit is contained in:
hodasemi 2023-09-21 11:22:03 +02:00
parent 00c8cef19d
commit 0712b88f72

View file

@ -1,11 +1,42 @@
fetch("/devices", {
method: "GET"
})
.then(response => {
const div = document.getElementById("main");
window.onload = startup;
let json = response.json();
async function startup() {
const response = await fetch(
"/devices",
{
method: "GET"
}
);
console.log(json);
const div = document.getElementById("main");
let json = await response.json();
console.log(json);
console.log(json["plugs"]);
Object.keys(json).forEach(entry => {
console.log(entry);
// const [group_name, devices] = entry;
// let group_label = document.createElement('label');
// group_label.innerText = group_name;
// div.appendChild(group_label);
// for (let i = 0; i < devices.length; i++) {
// let device_div = document.createElement('div');
// let dev_name = document.createElement('label');
// dev_name.innerText = devices[i][0];
// device_div.appendChild(dev_name);
// div.appendChild(device_div);
// }
})
.catch(error => console.error(error));
}