Skip to content

Commit 29f95ae

Browse files
committed
docs: use splitSetCookieString from cookie-es
1 parent 59f0099 commit 29f95ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/1.getting-started/6.data-fetching.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,15 @@ Be very careful before proxying headers to an external API and just include head
466466
If you want to pass on/proxy cookies in the other direction, from an internal request back to the client, you will need to handle this yourself.
467467

468468
```ts [composables/fetch.ts]
469-
import { appendResponseHeader, H3Event, splitCookiesString } from 'h3'
469+
import { appendResponseHeader } from 'h3'
470+
import type { H3Event } from 'h3'
471+
import { splitSetCookieString } from 'cookie-es'
470472

471473
export const fetchWithCookie = async (event: H3Event, url: string) => {
472474
/* Get the response from the server endpoint */
473475
const res = await $fetch.raw(url)
474476
/* Get the cookies from the response */
475-
const cookies = splitCookiesString(res.headers.get('set-cookie') || '')
477+
const cookies = splitSetCookieString(res.headers.get('set-cookie') || '')
476478
/* Attach each cookie to our incoming Request */
477479
for (const cookie of cookies) {
478480
appendResponseHeader(event, 'set-cookie', cookie)

0 commit comments

Comments
 (0)