From e2d8566500341bb12345fb603cc66882a2699909 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Tue, 9 Apr 2024 21:24:31 +0200 Subject: [PATCH] added searchStation function --- index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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*/ }) }