Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
8fdb93d7
Unverified
Commit
8fdb93d7
authored
Sep 22, 2020
by
Gergo Tolnai
Committed by
GitHub
Sep 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs(api-middlewares): use typings for serialize options from @types/cookie (#17285)
parent
beeeba09
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
+2
-7
api-middlewares.md
docs/api-routes/api-middlewares.md
+2
-7
No files found.
docs/api-routes/api-middlewares.md
View file @
8fdb93d7
...
...
@@ -124,23 +124,18 @@ For better type-safety, it is not recommended to extend the `req` and `res` obje
```
ts
// utils/cookies.ts
import
{
serialize
}
from
'cookie'
import
{
serialize
,
CookieSerializeOptions
}
from
'cookie'
import
{
NextApiResponse
}
from
'next'
/**
* This sets `cookie` using the `res` object
*/
type
Options
=
{
expires
?:
Date
maxAge
?:
number
}
export
const
setCookie
=
(
res
:
NextApiResponse
,
name
:
string
,
value
:
unknown
,
options
:
Options
=
{}
options
:
CookieSerialize
Options
=
{}
)
=>
{
const
stringValue
=
typeof
value
===
'object'
?
'j:'
+
JSON
.
stringify
(
value
)
:
String
(
value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment