Skip to content

Commit

Permalink
example: use top-level await 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Dec 28, 2022
1 parent 8556afd commit fbec080
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,42 @@ const hafas = createHafas('bvg-hafas-example')
const spichernstr = '900000042101'
const bismarckstr = '900000024201'

hafas.journeys(spichernstr, bismarckstr, {
// let data = await hafas.locations('Alexanderplatz', {results: 2})
// let data = await hafas.nearby(52.5137344, 13.4744798, {distance: 60})
// let data = await hafas.stop(bismarckstr)
// let data = await hafas.departures(spichernstr, {duration: 1})

let data = await hafas.journeys(spichernstr, bismarckstr, {
results: 1,
tickets: true,
stopovers: true,
transferInfo: true
})

// hafas.journeys({
// let data = await hafas.journeys({
// type: 'location',
// id: '900981377',
// name: 'Berlin, HTW-Berlin Campus Wilhelminenhof',
// latitude: 52.458359,
// longitude: 13.526635
// }, '900000192001', {results: 1})
// hafas.departures('900000013102', {duration: 1})
// hafas.locations('Alexanderplatz', {results: 2})
// hafas.stop('900000017104')
// hafas.nearby(52.5137344, 13.4744798, {distance: 60})
// hafas.radar({
// {
// const [journey] = data.journeys
// data = await hafas.refreshJourney(journey.refreshToken, {
// stopovers: true,
// transferInfo: true,
// })
// }
// {
// const [journey] = data.journeys
// const leg = journey.legs[0]
// data = await hafas.trip(leg.tripId, leg.line.name, {polyline: true})
// }

// let data = await hafas.radar({
// north: 52.52411,
// west: 13.41002,
// south: 52.51942,
// east: 13.41709
// }, {results: 10})

.then((data) => {
console.log(inspect(data, {depth: null, colors: true}))
})
.catch((err) => {
console.error(err)
process.exitCode = 1
})
console.log(inspect(data, {depth: null, colors: true}))

0 comments on commit fbec080

Please sign in to comment.