File size: 780 Bytes
1e92f2d |
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 |
import { cookies } from 'next/headers'
import { Suspense } from 'react'
const patchFetch = (originalFetch) => async (url, options) => {
const res = await originalFetch(url, options)
return res
}
const customFetch = patchFetch(fetch)
export default async function Page() {
const data = await customFetch(
'https://next-data-api-endpoint.vercel.app/api/random?revalidate-3',
{
next: {
revalidate: 3,
},
}
).then((res) => res.text())
return (
<>
<div id="random">{data}</div>
<Suspense fallback={<div>Loading...</div>}>
<DynamicThing />
</Suspense>
</>
)
}
async function DynamicThing() {
const cookieStore = await cookies()
const cookie = cookieStore.get('name')
return <div>{cookie}</div>
}
|