Skip to content

Commit

Permalink
docs: adding changes to setCookie example (vercel#36870)
Browse files Browse the repository at this point in the history
fixes vercel#28453

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [X] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [X] Make sure the linting passes by running `yarn lint`
  • Loading branch information
Sagnik Chatterjee authored May 13, 2022
1 parent 2b88467 commit 3674cad
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions docs/api-routes/api-middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ export const setCookie = (
const stringValue =
typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value)

if ('maxAge' in options) {
options.expires = new Date(Date.now() + options.maxAge)
options.maxAge /= 1000
if (typeof options.maxAge === 'number') {
options.expires = new Date(Date.now() + options.maxAge * 1000)
}

res.setHeader('Set-Cookie', serialize(name, stringValue, options))
Expand Down

0 comments on commit 3674cad

Please sign in to comment.