Files
homepage-Mirror/src/pages/api/widgets/openweathermap.js
2022-08-27 14:28:47 +03:00

10 lines
332 B
JavaScript

import cachedFetch from "utils/cached-fetch";
export default async function handler(req, res) {
const { lat, lon, apiKey, duration, units } = req.query;
const api_url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${apiKey}&units=${units}`;
res.send(await cachedFetch(api_url, duration));
}