rsnext/packages/next/server/web/spec-extension
Kiko Beats cc8ab99a92
Edge Cookies: Add .getWithOptions method (#36943)
Hello,

This is an iteration after first work at https://github.com/vercel/next.js/pull/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' }
```
2022-05-19 13:04:58 +00:00
..
cookies.ts Edge Cookies: Add .getWithOptions method (#36943) 2022-05-19 13:04:58 +00:00
fetch-event.ts Add deprecated JSDoc comments for the previous middleware signature (#35448) 2022-03-28 21:15:08 +00:00
request.ts feat: better cookies API for Edge Functions (#36478) 2022-05-09 09:50:32 +00:00
response.ts feat: better cookies API for Edge Functions (#36478) 2022-05-09 09:50:32 +00:00