location getting passed as prop now
This commit is contained in:
parent
910e61e51c
commit
c33c7568d1
@ -54,6 +54,7 @@ interface LocationType {
|
||||
latitude: string;
|
||||
longtitude: string;
|
||||
}
|
||||
const kelvin = 273.15;
|
||||
|
||||
async function getForecast(location: LocationType): Promise<Forecast> {
|
||||
const {latitude, longtitude} = location;
|
||||
@ -65,12 +66,15 @@ async function getForecast(location: LocationType): Promise<Forecast> {
|
||||
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 temp = weather.main.temp - kelvin
|
||||
return (
|
||||
<main>
|
||||
<h1>Forecast</h1>
|
||||
<p>{weather.name}</p>
|
||||
<p>{temp}</p>
|
||||
<p></p>
|
||||
</main>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user