added searchStation function
This commit is contained in:
parent
bc575e6787
commit
e2d8566500
18
index.js
18
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*/
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user