Download next.js/examples/api-routes-middleware/pages/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 392 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/api-routes-middleware/pages/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/examples/api-routes-middleware/pages/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/api-routes-middleware/pages/index.tsx
392 Bytes
| import useSWR from "swr"; | |
| const fetcher = (url: string) => fetch(url).then((res) => res.text()); | |
| export default function Index() { | |
| const { data, error, isLoading } = useSWR<string>("/api/cookies", fetcher); | |
| if (error) return <div>Failed to load</div>; | |
| if (isLoading) return <div>Loading...</div>; | |
| if (!data) return null; | |
| return <div>{`Cookie from response: "${data}"`}</div>; | |
| } | |