better error handling for api.weather.gov

This commit is contained in:
Matt Walsh
2020-09-09 15:23:19 -05:00
parent 9a09ccd1ea
commit eb321005d9
12 changed files with 39 additions and 69 deletions

View File

@@ -59,6 +59,14 @@ class TravelForecast extends WeatherDisplay {
// wait for all forecasts
const forecasts = await Promise.all(forecastPromises);
this.data = forecasts;
// test for some data available in at least one forecast
const hasData = this.data.reduce((acc,forecast) => acc || forecast.high, false);
if (!hasData) {
this.setStatus(STATUS.noData);
return;
}
this.drawCanvas(true);
}