mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 23:38:46 +00:00
Openmeteo Widget
This commit is contained in:
parent
13f622b323
commit
e1a62a69f6
5 changed files with 204 additions and 0 deletions
8
src/pages/api/widgets/openmeteo.js
Normal file
8
src/pages/api/widgets/openmeteo.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { latitude, longitude, units, cache } = req.query;
|
||||
const degrees = units === "imperial" ? "fahrenheit" : "celsius";
|
||||
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=sunrise,sunset¤t_weather=true&temperature_unit=${degrees}&timezone=auto`;
|
||||
return res.send(await cachedFetch(apiUrl, cache));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue