Skip to content

Commit

Permalink
feat: add climate-page with SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindis committed Mar 29, 2022
1 parent 3e8612a commit a1b295a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pages/climate/index.tsx
Original file line number Diff line number Diff line change
@@ -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<Props> = () => {
const [locations, setLocations] = useState<Location[]>([]);
const Climate: NextPage<Props> = ({ data: locations}) => {
const { READING_BASE_URI } = env;

useEffect(() => {
getLocations().then(locations => setLocations(locations))
}, [])

return (
<div>
<div>Climate Page12</div>
Expand All @@ -35,4 +31,9 @@ const Climate: NextPage<Props> = () => {
)
}

export async function getServerSideProps() {
const data = await getLocations();
return { props: { data } }
}

export default Climate;

0 comments on commit a1b295a

Please sign in to comment.