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 19, 2022
1 parent b5f083f commit 0e43ec2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "eslint:recommended",
"env": {
"es2021": true,
"es2022": true,
"node": true
},
"parserOptions": {
Expand Down
43 changes: 24 additions & 19 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,34 @@ const hafas = createHafas('db-hafas-example')
// retryOpts: {retries: 2}
// })

// let data = await hafas.locations('Berlin Jungfernheide')
// let data = await hafas.locations('ATZE Musiktheater', {poi: true, addressses: false, fuzzy: false})
// let data = await hafas.nearby(52.4751309, 13.3656537, {results: 1})
// let data = await hafas.stop('8089083')

// let data = await hafas.departures('8011167', {duration: 1})

// Berlin Jungfernheide to München Hbf
hafas.journeys('8011167', '8000261', {results: 1})
// hafas.departures('8011167', {duration: 1})
// hafas.locations('Berlin Jungfernheide')
// hafas.locations('ATZE Musiktheater', {poi: true, addressses: false, fuzzy: false})
// hafas.stop('8089083')
// hafas.nearby(52.4751309, 13.3656537, {results: 1})
// hafas.radar({
let data = await hafas.journeys('8011167', '8000261', {results: 1})
// {
// const [journey] = data.journeys
// data = await hafas.refreshJourney(journey.refreshToken, {
// stopovers: 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.5522,
// west: 13.3489,
// south: 52.5405,
// east: 13.3705
// }, {results: 10})

// .then(({journeys}) => {
// const leg = journeys[0].legs[0]
// return hafas.trip(leg.tripId, leg.line.name, {polyline: true})
// })

.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 0e43ec2

Please sign in to comment.