forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edge Cookies: Add
.getWithOptions
method (vercel#36943)
Hello, This is an iteration after first work at vercel#36478. What that PR missed is a way to just get a cookie value. Well, this PR adds two new things: `cookies.get` returns the cookie value that could be `string | undefined`: ```js const response = new NextResponse() response.cookies.set('foo', 'bar', { path: '/test' }) const value = response.cookies.get('foo') console.log(value) // => 'bar' ``` Additionally, if you want to know all the cookie details, you can use `cookies.getWithOptions`: ```js const response = new NextResponse() response.cookies.set('foo', 'bar', { path: '/test' }) const { value, options } response.cookies.getWithOptions('foo') console.log(value) // => 'bar' console.log(options) // => { Path: '/test' } ```
- Loading branch information
Showing
3 changed files
with
71 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters