Skip to content

Commit

Permalink
Fix: use same unit default for openmeteo widget and api (#4227)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon authored Oct 31, 2024
1 parent 3af86ff commit 3736c1f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pages/api/widgets/openmeteo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cachedFetch from "utils/proxy/cached-fetch";

export default async function handler(req, res) {
const { latitude, longitude, units, cache, timezone } = req.query;
const degrees = units === "imperial" ? "fahrenheit" : "celsius";
const degrees = units === "metric" ? "celsius" : "fahrenheit";
const timezeone = timezone ?? "auto";
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=sunrise,sunset&current_weather=true&temperature_unit=${degrees}&timezone=${timezeone}`;
return res.send(await cachedFetch(apiUrl, cache));
Expand Down

0 comments on commit 3736c1f

Please sign in to comment.