diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js index 8ae2e991f868046338a789d54fd08b97598fa7ec..28d88cba7a20b40a7965f1d53c7cf86fbb1815b6 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))) - */ + })