diff --git a/index.js b/index.js index 8e895ef..45ba4e5 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,15 @@ const MAX_DISPLAYED_VIAS = 4 +function searchStation(query) { + return fetch(`https://displays.api.sbb.ch/internal/api/v1/betriebspunkt?query=${query}`, { + headers: { + "X-API-Key": API_KEY + } + }).then(res => { + return res.json() + }) +} + function fetchInfo(bpuic) { return fetch(`https://displays.api.sbb.ch/internal/api/v1/data/${bpuic}`, { headers: { @@ -7,6 +17,14 @@ function fetchInfo(bpuic) { } }).then(res => { return res.json() + /* + }).then(res => { + const trains = res.contents[0].verkehrsmittels + console.log(`${trains.length} trains`) + let platforms = trains.map(t => t.gleisAbIst) + platforms = [... new Set(platforms)] + console.log(`Platforms: ${platforms.sort()}`) + return res*/ }) }