From a4a73b84cc0ffd08e4f0548f13b785da78ebf4a3 Mon Sep 17 00:00:00 2001 From: sietse jonker Date: Mon, 1 Apr 2024 11:58:39 +0200 Subject: [PATCH] Refactor fetchData function and add getLink function --- web/newWebsite/graph-main.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/newWebsite/graph-main.js b/web/newWebsite/graph-main.js index 5b6db31..8058f94 100644 --- a/web/newWebsite/graph-main.js +++ b/web/newWebsite/graph-main.js @@ -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");