mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
docs: Cookies store access is async (#83987)
Noted through a feedback channel.
This commit is contained in:
@@ -24,9 +24,10 @@ import { cookies } from 'next/headers'
|
||||
|
||||
async function getCookieData() {
|
||||
return new Promise((resolve) =>
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
// cookies will be called outside of the async context, causing a build-time error
|
||||
resolve(cookies().getAll())
|
||||
const cookieStore = await cookies()
|
||||
resolve(cookieStore.getAll())
|
||||
}, 1000)
|
||||
)
|
||||
}
|
||||
@@ -50,7 +51,8 @@ export default async function Page() {
|
||||
import { cookies } from 'next/headers'
|
||||
|
||||
async function getCookieData() {
|
||||
const cookieData = cookies().getAll()
|
||||
const cookieStore = await cookies()
|
||||
const cookieData = cookieStore.getAll()
|
||||
return new Promise((resolve) =>
|
||||
setTimeout(() => {
|
||||
resolve(cookieData)
|
||||
|
||||
Reference in New Issue
Block a user