Update use-request-fetch.md

This commit is contained in:
Daniel Roe 2024-09-21 09:35:26 +01:00 committed by GitHub
parent 5b4527f20b
commit d7d45bca3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -28,7 +28,8 @@ The [`useFetch`](/docs/api/composables/use-fetch) composable uses `useRequestFet
<script setup lang="ts">
// This will forward the user's headers to the `/api/foo` event handler
// Result: { cookies: { foo: 'bar' } }
const { data: forwarded } = await useAsyncData(() => useRequestFetch()('/api/cookies'))
const requestFetch = useRequestFetch()
const { data: forwarded } = await useAsyncData(() => requestFetch('/api/cookies'))
// This will NOT forward anything
// Result: { cookies: {} }