homepage/src/pages/api/widgets/openweathermap.js

10 lines
332 B
JavaScript
Raw Normal View History

2022-08-27 13:30:17 +03:00
import cachedFetch from "utils/cached-fetch";
export default async function handler(req, res) {
2022-08-27 14:28:47 +03:00
const { lat, lon, apiKey, duration, units } = req.query;
2022-08-27 13:30:17 +03:00
2022-08-27 14:28:47 +03:00
const api_url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${apiKey}&units=${units}`;
2022-08-27 13:30:17 +03:00
res.send(await cachedFetch(api_url, duration));
}