diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js index 714407c9474912ba3f34cb43aab151ce2bd5e24e..a51428110b344c78b5c91f30517bde2ff4a2e1fb 100644 --- a/public/js/connectToAPI.js +++ b/public/js/connectToAPI.js @@ -5,7 +5,7 @@ var url2 = "http://vm24.fkc.hft-stuttgart.de:8082/workflow/timedShadowValueByDay /*TODO#1: -get current data from the api and create local test data (apiData foler) -add connection handeling (error messages when there isnt a connection and then using the local test data) */ - +var localShadowData = "/3dclient4simstadtapi/public/test/APIdata/shadowData.json" var buildingFunctionSort var constructionYearSortPick @@ -91,19 +91,25 @@ const response = await fetch(url, { document.getElementById("loader").style.visibility = "hidden" +async function getLocalShadowdata(){ + // gets the response from the api 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() { console.log(coordinatesBB) console.log("Waiting for data....") - - - timeout(25000, fetchshadowDataJSON()).then((response)=>{ console.log(response) shadowdata = response ; }).catch((error)=>{ //catching the error(no connection)/ timeout and displaying an alert for the user - - console.log("Using local test data"); + // shadowdata= getLocalShadowdata(); + console.log(shadowdata); //loadLocalAPIshadowData here... })