Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Added await to cookies().get() promise #1365

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hefler
Copy link

@hefler hefler commented Sep 19, 2024

What does this PR do?

cookies().get() is an asynchronous function. Adding await to the sample code ensures that the cookie is read prior to moving to the next instructions. Not handling this as a promise makes it prone for the code to not run as intended and hard to debug.

Test Plan

Not needed, sample code just follows the standards https://wicg.github.io/cookie-store/#CookieStore-get

Related PRs and Issues

Fixes #1364

Have you read the Contributing Guidelines on issues?

Yes

@coolify-appwrite-org
Copy link

coolify-appwrite-org bot commented Sep 19, 2024

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2024-09-19 15:28:51 CET

@@ -20,7 +20,7 @@ export async function createSessionClient() {
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT);

const session = cookies().get("my-custom-session");
const session = await cookies().get("my-custom-session");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be (await cookies()).get("my-custom-session"); ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📚 Documentation: add await to cookies().get() as it returns a promise next.js-ssr-auth demo
2 participants