Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
docs: use updated h3 utils (#6818)
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Aug 22, 2022
1 parent d3ccb79 commit ae39a82
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/content/2.guide/2.features/9.server-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default defineEventHandler((event) => {

```ts
export default defineEventHandler((event) => {
const cookies = useCookies(event)
const cookies = parseCookies(event)
return { cookies }
})
```
Expand Down
4 changes: 2 additions & 2 deletions docs/content/3.api/1.composables/use-cookie.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ Specifies a function that returns the cookie's default value. The function can a

## Handling Cookies in API Routes

You can use `useCookie` and `setCookie` from [`h3`](https://github.com/unjs/h3) package to set cookies in server API routes.
You can use `getCookie` and `setCookie` from [`h3`](https://github.com/unjs/h3) package to set cookies in server API routes.

**Example:**

```js
export default defineEventHandler(event => {
// Read counter cookie
let counter = useCookie(event, 'counter') || 0
let counter = getCookie(event, 'counter') || 0

// Increase counter cookie by 1
setCookie(event, 'counter', ++counter)
Expand Down

0 comments on commit ae39a82

Please sign in to comment.