diff --git a/lib/repack-text-forecast.js b/lib/repack-text-forecast.js index 14f0b34..073a66b 100644 --- a/lib/repack-text-forecast.js +++ b/lib/repack-text-forecast.js @@ -1,6 +1,8 @@ module.exports = (textForecast, areaIds) => { return textForecast.textforecast.time.map(period => { - const areas = period.forecasttype.location + const { forecasttype } = period + + const areas = forecasttype && forecasttype.location ? forecasttype.location : [] const filteredAreas = areaIds ? areas.filter(area => areaIds.includes(area['@_id'])) : areas const areaForcasts = filteredAreas.map(area => {