Unverified Commit 8fdb93d7 authored by Gergo Tolnai's avatar Gergo Tolnai Committed by GitHub

Docs(api-middlewares): use typings for serialize options from @types/cookie (#17285)

parent beeeba09
......@@ -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: CookieSerializeOptions = {}
) => {
const stringValue =
typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment