diff --git a/js/app.js b/js/app.js index 3819b65..bc276cf 100644 --- a/js/app.js +++ b/js/app.js @@ -425,7 +425,7 @@ const app = () => { }; //add from local to ui - const getTerminus = () => { + const getTerminus = async () => { let terminus; if (localStorage.getItem("terminus") === null) { terminus = []; @@ -440,14 +440,14 @@ const app = () => { directions = JSON.parse(localStorage.getItem("directions")); } - const getData = async (arg) => { - let API_URL = - "https://ckan.multimediagdansk.pl/dataset/c24aa637-3619-4dc2-a171-a23eec8f2172/resource/d3e96eb6-25ad-4d6c-8651-b1eb39155945/download/stopsingdansk.json"; - let response = await fetch(API_URL); - let data = await response.json(); + const API_URL = + "https://ckan.multimediagdansk.pl/dataset/c24aa637-3619-4dc2-a171-a23eec8f2172/resource/d3e96eb6-25ad-4d6c-8651-b1eb39155945/download/stopsingdansk.json"; - const { stops, stopId, stopName, stopCode, zoneId } = data; + let response = await fetch(API_URL); + let data = await response.json(); + const { stops, stopId, stopName, stopCode, zoneId } = data; + const getData = async (arg) => { let input = arg; let ID; let dataArr = []; @@ -464,9 +464,9 @@ const app = () => { } } - API_URL = `https://ckan2.multimediagdansk.pl/delays?stopId=${ID}`; + const ID_API_URL = `https://ckan2.multimediagdansk.pl/delays?stopId=${ID}`; - response = await fetch(API_URL); + response = await fetch(ID_API_URL); data = await response.json(); const { delay, estimatedTime, routeId, headsign } = data; diff --git a/js/directSearchApp.js b/js/directSearchApp.js index 8564869..3d160dd 100644 --- a/js/directSearchApp.js +++ b/js/directSearchApp.js @@ -273,7 +273,7 @@ const app = () => { }; //add from local to ui - const getDirect = () => { + const getDirect = async () => { let direct; if (localStorage.getItem("direct") === null) { direct = []; @@ -281,14 +281,14 @@ const app = () => { direct = JSON.parse(localStorage.getItem("direct")); } - const getData = async (arg) => { - let API_URL = - "https://ckan.multimediagdansk.pl/dataset/c24aa637-3619-4dc2-a171-a23eec8f2172/resource/d3e96eb6-25ad-4d6c-8651-b1eb39155945/download/stopsingdansk.json"; - let response = await fetch(API_URL); - let data = await response.json(); + const API_URL = + "https://ckan.multimediagdansk.pl/dataset/c24aa637-3619-4dc2-a171-a23eec8f2172/resource/d3e96eb6-25ad-4d6c-8651-b1eb39155945/download/stopsingdansk.json"; + let response = await fetch(API_URL); + let data = await response.json(); - const { stops, stopId, stopName, stopCode, zoneId } = data; + const { stops, stopId, stopName, stopCode, zoneId } = data; + const getData = async (arg) => { let input = arg; let words = input.split(" "); let code = words[words.length - 1]; @@ -312,9 +312,9 @@ const app = () => { } } - API_URL = `https://ckan2.multimediagdansk.pl/delays?stopId=${ID}`; + ID_API_URL = `https://ckan2.multimediagdansk.pl/delays?stopId=${ID}`; - response = await fetch(API_URL); + response = await fetch(ID_API_URL); data = await response.json(); const { delay, estimatedTime, routeId, headsign } = data;