pre-load wfo point info for regional and travel cities

This commit is contained in:
Matt Walsh
2022-11-22 14:17:04 -06:00
parent 33570a8030
commit 2675ff8f16
14 changed files with 2945 additions and 18 deletions

View File

@@ -29,8 +29,8 @@ class TravelForecast extends WeatherDisplay {
const forecastPromises = TravelCities.map(async (city) => {
try {
// get point then forecast
const point = await utils.weather.getPoint(city.Latitude, city.Longitude);
const forecast = await utils.fetch.json(point.properties.forecast);
if (!city.point) throw new Error('No pre-loaded point');
const forecast = await utils.fetch.json(`https://api.weather.gov/gridpoints/${city.point.wfo}/${city.point.x},${city.point.y}/forecast`);
// determine today or tomorrow (shift periods by 1 if tomorrow)
const todayShift = forecast.properties.periods[0].isDaytime ? 0 : 1;
// return a pared-down forecast