/
index.tsx
41 lines (35 loc) · 1.08 KB
/
index.tsx
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
40
41
import Head from 'next/head'
import Image from 'next/image'
import { Inter } from 'next/font/google'
import styles from '@/styles/Home.module.css'
import useSWR from "swr";
const inter = Inter({ subsets: ['latin'] })
// @ts-ignore
const fetcher = (...args: any[]) => fetch(...args).then(res => res.json())
export default function Home() {
const {data} = useSWR('https://catfact.ninja/fact', fetcher,
{
focusThrottleInterval: 60_000
});
return (
<>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={`${styles.main} ${inter.className}`}>
<div className={styles.description}>
<p>
Get started by editing
<code className={styles.code}>src/pages/index.tsx</code>
</p>
<p>
{data && JSON.stringify(data)}
</p>
</div>
</main>
</>
)
}