Download next.js/test/e2e/app-dir/actions/app/header/actions.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 686 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/header/actions.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/actions/app/header/actions.ts
-
curl -L -o actions.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/header/actions.ts
686 Bytes
| 'use server' | |
| import { headers, cookies } from 'next/headers' | |
| import { redirect } from 'next/navigation' | |
| export async function setCookieWithMaxAge() { | |
| ;(await cookies()).set({ | |
| name: 'foo', | |
| value: 'bar', | |
| maxAge: 1000, | |
| }) | |
| } | |
| export async function getCookie(name) { | |
| return (await cookies()).get(name) | |
| } | |
| export async function getHeader(name) { | |
| return (await headers()).get(name) | |
| } | |
| export async function setCookie(name, value) { | |
| const localCookies = await cookies() | |
| localCookies.set(name, value) | |
| return localCookies.get(name) | |
| } | |
| export async function setCookieAndRedirect(name, value, path, type) { | |
| ;(await cookies()).set(name, value) | |
| redirect(path, type) | |
| } | |