hafas-find-alternative-legs
Version:
Given a journey, get alternatives for each leg from HAFAS.
43 lines (28 loc) • 1.7 kB
Markdown
# hafas-find-alternative-legs
**Given a [`hafas-client`](https://npmjs.com/package/hafas-client) journey, get alternatives for each leg from HAFAS.**
[](https://www.npmjs.com/package/hafas-find-alternative-legs)
[](https://travis-ci.org/derhuerst/hafas-find-alternative-legs)

[](https://gitter.im/derhuerst)
[](https://patreon.com/derhuerst)
## Installation
```shell
npm install hafas-find-alternative-legs
```
## Usage
```js
const createHafas = require('bvg-hafas')
const createFetchAlternatives = require('hafas-find-alternative-legs')
const hafas = createHafas('my awesome program')
const fetchAlternatives = createFetchAlternatives(hafas)
const friedrichstr = '900000100001'
const senefelderplatz = '900000110005'
hafas.journeys(friedrichstr, senefelderplatz, {results: 1})
.then(([journey]) => fetchAlternatives(journey))
.then((journeyWithAlternatives) => {
console.log(journeyWithAlternatives.legs)
})
.catch(console.error)
```
## Contributing
If you have a question or need support using `hafas-find-alternative-legs`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/hafas-find-alternative-legs/issues).