From 29f95ae0d4083759a1a6939ab79e6b4b28327fef Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 21 Jul 2024 21:21:30 +0200 Subject: [PATCH] docs: use `splitSetCookieString` from `cookie-es` --- docs/1.getting-started/6.data-fetching.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/1.getting-started/6.data-fetching.md b/docs/1.getting-started/6.data-fetching.md index 0e8bb2a0c3..e80ae4023b 100644 --- a/docs/1.getting-started/6.data-fetching.md +++ b/docs/1.getting-started/6.data-fetching.md @@ -466,13 +466,15 @@ Be very careful before proxying headers to an external API and just include head 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. ```ts [composables/fetch.ts] -import { appendResponseHeader, H3Event, splitCookiesString } from 'h3' +import { appendResponseHeader } from 'h3' +import type { H3Event } from 'h3' +import { splitSetCookieString } from 'cookie-es' export const fetchWithCookie = async (event: H3Event, url: string) => { /* Get the response from the server endpoint */ const res = await $fetch.raw(url) /* Get the cookies from the response */ - const cookies = splitCookiesString(res.headers.get('set-cookie') || '') + const cookies = splitSetCookieString(res.headers.get('set-cookie') || '') /* Attach each cookie to our incoming Request */ for (const cookie of cookies) { appendResponseHeader(event, 'set-cookie', cookie)