diff --git a/src/components/Weather.tsx b/src/components/Weather.tsx index a23a286..cf94ffc 100644 --- a/src/components/Weather.tsx +++ b/src/components/Weather.tsx @@ -38,6 +38,8 @@ export function Weather() { temperature: number; temperatureUnit: string; shortForecast: string; + city: string; + state: string; } | null>(null); const [error, setError] = useState(null); @@ -74,6 +76,9 @@ export function Weather() { {weather.temperatureUnit}
{weather.shortForecast}
+
+ {weather.city}, {weather.state} +
diff --git a/src/index.ts b/src/index.ts index 67c5edc..a59c74e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -95,13 +95,25 @@ const server = serve({ const pointsResponse = await fetch( `https://api.weather.gov/points/${lat},${lon}`, + { + headers: { + "User-Agent": "(watsup, aly@aly.codes)", + }, + }, ); const pointsData = await pointsResponse.json(); const forecastUrl = pointsData.properties.forecast; const forecastResponse = await fetch(forecastUrl); const forecastData = await forecastResponse.json(); - return Response.json(forecastData.properties.periods[0]); + + const location = pointsData.properties.relativeLocation.properties; + + return Response.json({ + ...forecastData.properties.periods[0], + city: location.city, + state: location.state, + }); }, },