From e674f60c004b09c9e20a42083161922bb013e6e8 Mon Sep 17 00:00:00 2001 From: Ash Go <105261105+ashgo-x@users.noreply.github.com> Date: Fri, 10 Jun 2022 21:49:34 +0800 Subject: [PATCH 1/3] docs: cookie example --- docs/content/3.api/1.composables/use-cookie.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/content/3.api/1.composables/use-cookie.md b/docs/content/3.api/1.composables/use-cookie.md index 1bc2a0fec5a..ced567bd858 100644 --- a/docs/content/3.api/1.composables/use-cookie.md +++ b/docs/content/3.api/1.composables/use-cookie.md @@ -143,18 +143,16 @@ You can use `useCookie` and `setCookie` from [`h3`](https://github.com/unjs/h3) **Example:** ```js -import { useCookie, setCookie } from 'h3' - -export default (req, res) => { +export default defineEventHandler((event)=>{ // Read counter cookie - let counter = useCookie(req, 'counter') || 0 + let counter = useCookie(event, 'counter') || 0 // Increase counter cookie by 1 setCookie(res, 'counter', ++counter) // Send JSON response return { counter } -} +}) ``` :LinkExample{link="/examples/composables/use-cookie"} From 2a526b7d315010e87ea61b06783801274e059ae4 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Fri, 10 Jun 2022 15:56:26 +0200 Subject: [PATCH 2/3] Update docs/content/3.api/1.composables/use-cookie.md --- docs/content/3.api/1.composables/use-cookie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/3.api/1.composables/use-cookie.md b/docs/content/3.api/1.composables/use-cookie.md index ced567bd858..2c4b7cdd552 100644 --- a/docs/content/3.api/1.composables/use-cookie.md +++ b/docs/content/3.api/1.composables/use-cookie.md @@ -148,7 +148,7 @@ export default defineEventHandler((event)=>{ let counter = useCookie(event, 'counter') || 0 // Increase counter cookie by 1 - setCookie(res, 'counter', ++counter) + setCookie(event, 'counter', ++counter) // Send JSON response return { counter } From 332ace95d7959258104443a54da379992b1469ef Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Fri, 10 Jun 2022 15:57:24 +0200 Subject: [PATCH 3/3] Update docs/content/3.api/1.composables/use-cookie.md --- docs/content/3.api/1.composables/use-cookie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/3.api/1.composables/use-cookie.md b/docs/content/3.api/1.composables/use-cookie.md index 2c4b7cdd552..c801238c967 100644 --- a/docs/content/3.api/1.composables/use-cookie.md +++ b/docs/content/3.api/1.composables/use-cookie.md @@ -143,7 +143,7 @@ You can use `useCookie` and `setCookie` from [`h3`](https://github.com/unjs/h3) **Example:** ```js -export default defineEventHandler((event)=>{ +export default defineEventHandler(event => { // Read counter cookie let counter = useCookie(event, 'counter') || 0