Skip to content

Commit

Permalink
Don't throw on empty rates
Browse files Browse the repository at this point in the history
When getting rates with the `getLowestHotelPrices`
method, we might not get any rates back.
However, we shouldm't assume that this
means our `hotelCode` was wrong, It could
be the hotel isn't open during that period.
Instead, we should rely on an empty `currecyCode`.
  • Loading branch information
raphaelcockx committed Dec 19, 2022
1 parent b903239 commit 5d7bc1f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default class Trippe {
.then(hotel => {
const { currencyCode, rates } = hotel

if (rates.length === 0) {
if (currencyCode === '') {
throw new Error('Unknown or invalid hotelCode')
} else {
const ratesCombined = rates.flatMap(rate => rate.windows)
Expand Down

0 comments on commit 5d7bc1f

Please sign in to comment.