mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
fixed error from braces
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
// Selecteer alle knoppen en voeg een event listener toe aan elke knop
|
// Selecteer alle knoppen en voeg een event listener toe aan elke knop
|
||||||
document.querySelectorAll(".btn").forEach(button => {
|
document.querySelectorAll(".btn").forEach((button) => {
|
||||||
button.addEventListener("click", function(event) {
|
button.addEventListener("click", function (event) {
|
||||||
event.preventDefault(); // voorkomt pagina-verversing
|
event.preventDefault(); // voorkomt pagina-verversing
|
||||||
|
|
||||||
// Haal de waarde van de knop op
|
// Haal de waarde van de knop op
|
||||||
@@ -9,30 +9,30 @@ document.querySelectorAll(".btn").forEach(button => {
|
|||||||
fetch("/move", {
|
fetch("/move", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ direction: direction })
|
body: JSON.stringify({ direction: direction }),
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then(data => {
|
.then((data) => {
|
||||||
console.log("Success:", data);
|
console.log("Success:", data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch data from the server
|
// Fetch data from the server
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try{
|
try {
|
||||||
const response = await fetch("/data");
|
const response = await fetch("/data");
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Parse the data and show it on the website
|
// Parse the data and show it on the website
|
||||||
async function parseData() {
|
async function parseData() {
|
||||||
const data = await fetchData();
|
const data = await fetchData();
|
||||||
@@ -48,4 +48,4 @@ document.querySelectorAll(".btn").forEach(button => {
|
|||||||
|
|
||||||
// Fetch and display sensor data every 5 seconds
|
// Fetch and display sensor data every 5 seconds
|
||||||
setInterval(parseData, 5000);
|
setInterval(parseData, 5000);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user