Skip to content

Commit 1cf268e

Browse files
committed
fix: keep sponsor data composables in Nuxt context
Nuxt documents useFetch as a composable that should be called directly in setup, plugins, or route middleware so it can register payload state for hydration. Calling useFetch and useAsyncData directly in this composable keeps the Nuxt data primitives visible instead of hiding them behind a generic Promise.all boundary. The call sites can still include useSponsors() in their existing Promise.all arrays; Promise.all accepts plain values, and the composable keeps returning the same sponsors helpers. Docs: https://nuxt.com/docs/4.x/api/composables/use-fetch
1 parent 58070fe commit 1cf268e

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

app/composables/useSponsors.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { Sponsor } from '#shared/types'
22

3-
export const useSponsors = async () => {
4-
const [{ data: apiSponsors }, { data: manualSponsors }] = await Promise.all([
5-
useFetch('/api/sponsors', { key: 'sponsors' }),
6-
useAsyncData('manual-sponsors', () => queryCollection('manualSponsors').first())
7-
])
3+
export const useSponsors = () => {
4+
const { data: apiSponsors } = useFetch('/api/sponsors', { key: 'sponsors' })
5+
const { data: manualSponsors } = useAsyncData('manual-sponsors', () => queryCollection('manualSponsors').first())
86

97
const sponsors = computed(() => {
108
const manual = manualSponsors.value?.sponsors || []

0 commit comments

Comments
 (0)