From e3030f47594fb32c747a021ce68b78917f262419 Mon Sep 17 00:00:00 2001
From: Daria Kolokolnikova <72koda1bif@hft-stuttgart.de>
Date: Wed, 22 Dec 2021 00:32:44 +0100
Subject: [PATCH] -fixed bug in localshadowdata and localbuildinginformation

---
 public/js/connectToAPI.js | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js
index 8ae2e99..28d88cb 100644
--- a/public/js/connectToAPI.js
+++ b/public/js/connectToAPI.js
@@ -122,24 +122,23 @@ async function fetchDataJSON() {
 document.getElementById("loader").style.visibility = "hidden"
 
 async function getLocalShadowdata() {
-    // gets the response from the api and put it inside a constant
+    // gets the response from localShadowData and put it inside a constant
     const response = await fetch(localShadowData);
     //the response have to be converted to json type file, so it can be used
     const data = await response.json();
     console.log(data)
-    // shadowData=data;
     return data;
 }
 
-function processData() {
+async function processData() {
     console.log(coordinatesBB)
     console.log("Waiting for data....")
+    shadowdata= await getLocalShadowdata()
 
-    timeout(25000, fetchshadowDataJSON()).then((response) => {
+    timeout(25000, getLocalShadowdata()).then((response) => {
         console.log(response)
         shadowdata = response;
     }).catch((error) => { //catching the error(no connection)/ timeout and displaying an alert for the user
-        //  shadowdata=  getLocalShadowdata();
         console.log(shadowdata);
         //loadLocalAPIshadowData here...
     })
@@ -155,11 +154,11 @@ function processData() {
         calculateData(response);
     }).catch((error) => {
         console.log(error)
-        /*
+        
         fetch("/3dclient4simstadtapi/public/test/APIdata/buildingInformation.json")
         .then(response => response.text())
         .then(text => calculateData( JSON.parse(text)))
-        */
+        
     })
 
 
-- 
GitLab