location getting passed as prop now

This commit is contained in:
christian 2024-05-04 20:30:04 +02:00
parent 910e61e51c
commit c33c7568d1

View File

@ -54,6 +54,7 @@ interface LocationType {
latitude: string; latitude: string;
longtitude: string; longtitude: string;
} }
const kelvin = 273.15;
async function getForecast(location: LocationType): Promise<Forecast> { async function getForecast(location: LocationType): Promise<Forecast> {
const {latitude, longtitude} = location; const {latitude, longtitude} = location;
@ -65,12 +66,15 @@ async function getForecast(location: LocationType): Promise<Forecast> {
return res.json(); return res.json();
} }
export default async function Weather(location: LocationType) { export default async function Weather(props: {location: LocationType}) {
const location = props.location
const weather = await getForecast(location) const weather = await getForecast(location)
const temp = weather.main.temp - kelvin
return ( return (
<main> <main>
<h1>Forecast</h1> <h1>Forecast</h1>
<p>{weather.name}</p> <p>{temp}</p>
<p></p>
</main> </main>
); );
} }