added searchStation function

This commit is contained in:
Louis Heredero 2024-04-09 21:24:31 +02:00
parent bc575e6787
commit e2d8566500
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7

View File

@ -1,5 +1,15 @@
const MAX_DISPLAYED_VIAS = 4 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) { function fetchInfo(bpuic) {
return fetch(`https://displays.api.sbb.ch/internal/api/v1/data/${bpuic}`, { return fetch(`https://displays.api.sbb.ch/internal/api/v1/data/${bpuic}`, {
headers: { headers: {
@ -7,6 +17,14 @@ function fetchInfo(bpuic) {
} }
}).then(res => { }).then(res => {
return res.json() 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*/
}) })
} }