update ui

This commit is contained in:
madarsbiss 2021-07-27 16:25:09 +03:00
parent 548e68ab0f
commit 30003edea8

View File

@ -6,7 +6,6 @@ export default function Home() {
const [input, setInput] = useState("mumbai"); const [input, setInput] = useState("mumbai");
const [systemUsed, setSystemUsed] = useState("metric"); const [systemUsed, setSystemUsed] = useState("metric");
const [weatherData, setWeatherData] = useState(); const [weatherData, setWeatherData] = useState();
// const [isLoading, setIsLoading] = useState(true);
const getData = async () => { const getData = async () => {
const res = await fetch("/api/data", { const res = await fetch("/api/data", {
@ -15,6 +14,7 @@ export default function Home() {
body: JSON.stringify({ input }), body: JSON.stringify({ input }),
}); });
const data = await res.json(); const data = await res.json();
// console.log(data);
setWeatherData({ ...data }); setWeatherData({ ...data });
setInput(""); setInput("");
@ -83,13 +83,10 @@ export default function Home() {
} }
}; };
const changeSystem = () => { const changeSystem = () =>
if (systemUsed == "metric") { systemUsed == "metric"
setSystemUsed("imperial"); ? setSystemUsed("imperial")
} else { : setSystemUsed("metric");
setSystemUsed("metric");
}
};
var weekday = [ var weekday = [
"Sunday", "Sunday",
@ -314,6 +311,6 @@ export default function Home() {
</div> </div>
</div> </div>
) : ( ) : (
<h1>Loading results</h1> <h1>Loading data...</h1>
); );
} }