-
Notifications
You must be signed in to change notification settings - Fork 454
Expand file tree
/
Copy pathshows.tsx
More file actions
39 lines (32 loc) · 912 Bytes
/
shows.tsx
File metadata and controls
39 lines (32 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react';
import useApi from '../lib/use-api';
import Layout from '../components/layout';
import { withPageAuthRequired } from '@auth0/nextjs-auth0';
type TVShow = { show: { name: string } };
export default withPageAuthRequired(function TvShows(): React.ReactElement {
const { response, error, isLoading } = useApi('/api/shows');
return (
<Layout>
<h1>TV Shows</h1>
{isLoading && <p>Loading TV shows...</p>}
{response && (
<>
<p>My favourite TV shows:</p>
<pre>
{JSON.stringify(
response.shows.map((s: TVShow) => s.show.name),
null,
2
)}
</pre>
</>
)}
{error && (
<>
<p>Error loading TV shows</p>
<pre style={{ color: 'red' }}>{JSON.stringify(error, null, 2)}</pre>
</>
)}
</Layout>
);
});