import { useState } from "react"; import styles from "../styles/Home.module.css"; import Image from "next/image"; export default function Home() { const [input, setInput] = useState(); const [weatherData, setWeatherData] = useState(); const clickHandler = async () => { const res = await fetch("/api/data", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input }), }); const data = await res.json(); setWeatherData({ ...data }); console.log(data); }; return (
{/*

My weather app {input}

*/} {weatherData && ( <>

{weatherData.name}, {weatherData.sys.country}

{weatherData.weather[0].description}

weatherIcon

{Math.round(weatherData.main.temp)}°

Feels like {weatherData.main.feels_like}°

setInput(e.target.value)} /> )}
); }