remove blank travel forecast lines when there's a fetch error

This commit is contained in:
Matt Walsh 2022-11-14 14:23:31 -06:00
parent 7755090d32
commit e67774aa23
2 changed files with 433 additions and 481 deletions

907
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -44,7 +44,7 @@ class TravelForecast extends WeatherDisplay {
} catch (e) { } catch (e) {
console.error(`GetTravelWeather for ${city.Name} failed`); console.error(`GetTravelWeather for ${city.Name} failed`);
console.error(e.status, e.responseJSON); console.error(e.status, e.responseJSON);
return { name: city.Name }; return { name: city.Name, error: true };
} }
}); });
@ -72,6 +72,7 @@ class TravelForecast extends WeatherDisplay {
const cities = this.data; const cities = this.data;
const lines = cities.map((city) => { const lines = cities.map((city) => {
if (city.error) return false;
const fillValues = {}; const fillValues = {};
// city name // city name
@ -100,7 +101,7 @@ class TravelForecast extends WeatherDisplay {
fillValues.error = 'NO TRAVEL DATA AVAILABLE'; fillValues.error = 'NO TRAVEL DATA AVAILABLE';
} }
return this.fillTemplate('travel-row', fillValues); return this.fillTemplate('travel-row', fillValues);
}); }).filter((d) => d);
list.append(...lines); list.append(...lines);
} }