diff --git a/pages/climate/index.tsx b/pages/climate/index.tsx index 07d0d22..f78d1ce 100644 --- a/pages/climate/index.tsx +++ b/pages/climate/index.tsx @@ -1,21 +1,17 @@ import type { NextPage } from 'next'; import Link from 'next/link'; -import { useEffect, useState } from 'react'; import env from '../../env'; import { Location } from '../../types'; import { getLocations } from '../../services/api/climate/locations'; -interface Props {} +interface Props { + data: any; +} -const Climate: NextPage = () => { - const [locations, setLocations] = useState([]); +const Climate: NextPage = ({ data: locations}) => { const { READING_BASE_URI } = env; - useEffect(() => { - getLocations().then(locations => setLocations(locations)) - }, []) - return (
Climate Page12
@@ -35,4 +31,9 @@ const Climate: NextPage = () => { ) } +export async function getServerSideProps() { + const data = await getLocations(); + return { props: { data } } +} + export default Climate;