diff options
| author | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-08-25 23:12:48 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-08-25 23:12:48 +0200 |
| commit | dc20c2ba8377a90a3170642c9b3df6cd5166ad72 (patch) | |
| tree | 744a6ce5076fc3378ded6a08acca122637229afc /src/pages/Home.tsx | |
Initial commit
Diffstat (limited to 'src/pages/Home.tsx')
| -rw-r--r-- | src/pages/Home.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx new file mode 100644 index 0000000..79f1ec2 --- /dev/null +++ b/src/pages/Home.tsx @@ -0,0 +1,33 @@ +import useSWR from "swr"; + +interface Stop { + stopId: number + name: string; + latitude?: number; + longitude?: number; + lines: string[]; +} + +export function Home() { + const { data, error, isLoading } = useSWR<Stop[]>('home', async () => { + const response = await fetch('/api/ListStops') + return response.json() + }); + + if (isLoading) return <h1>Loading...</h1> + if (error) return <h1>Error</h1> + + return ( + <> + <h1>Home</h1> + + <ul> + {data?.map((stop: Stop) => ( + <li key={stop.stopId}> + {stop.name} - {stop.lines?.join(', ')} + </li> + ))} + </ul> + </> + ) +} |
