Download next.js/test/e2e/app-dir/app-static/app/unstable-cache/fetch/fetch.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 592 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/app-static/app/unstable-cache/fetch/fetch.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/app-static/app/unstable-cache/fetch/fetch.jsx
-
curl -L -o fetch.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/app-static/app/unstable-cache/fetch/fetch.jsx
592 Bytes
| import { unstable_cache } from 'next/cache' | |
| import { Suspense } from 'react' | |
| const getData = unstable_cache( | |
| async (cache) => { | |
| const res = await fetch( | |
| 'https://next-data-api-endpoint.vercel.app/api/random', | |
| { cache } | |
| ) | |
| return res.text() | |
| }, | |
| undefined, | |
| {} | |
| ) | |
| async function Data({ cache = undefined }) { | |
| const data = await getData(cache) | |
| return <div id="data">{data}</div> | |
| } | |
| export default function Page({ cache = undefined }) { | |
| return ( | |
| <Suspense fallback={<div id="loading">Loading...</div>}> | |
| <Data cache={cache} /> | |
| </Suspense> | |
| ) | |
| } | |