Refactor fetchData function and add getLink function

This commit is contained in:
sietse jonker
2024-04-01 11:58:39 +02:00
parent 0d86c6bcbd
commit a4a73b84cc

View File

@@ -1,8 +1,6 @@
// Sample data - you can replace this with your actual dataset
const data = [];
processor = new DataProcessor();
dateStart='2024-03-27%2011:47:11'
dateEnd="2024-03-27%2011:47:11"
// Function to create checkbox with label
function createCheckBox(id, label) {
@@ -110,9 +108,15 @@ function createFilterContainer() {
document.body.appendChild(container);
}
// Function to get the link for the get request
function getLink(startDate, endDate, node) {
return link = "http://getMeasurements?dateStart=" + startDate.toISOString() +
"&dateEnd=" + endDate.toISOString() +
"&node=" + node;
}
// Get request to fetch data from the server
function fetchData() {
fetch("http://145.92.8.114/getMeasurements?dateStart=2024-03-27%2011:47:11&dateEnd=2024-03-28%2011:47:11&node=113")
function fetchData(link) {
fetch(link)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");