forecast/pages/api/data.js
2021-10-27 13:38:28 +03:00

9 lines
326 B
JavaScript

export default async function handler(req, res) {
const { cityInput } = req.body;
const getWeatherData = await fetch(
`https://api.openweathermap.org/data/2.5/weather?q=${cityInput}&units=metric&appid=${process.env.OPENWEATHER_API_KEY}`
);
const data = await getWeatherData.json();
res.status(200).json(data);
}