NuxtN
Nuxt15mo ago
9 replies
Samuelreichoer

Fetch Data server and client side module recommended way

I am building a querybuilder for Craft CMS and I need to somehow make fetches on client and server side. I tried to do that with useFetch like that

async function fetchFn(url: string): Promise<FetchResult> {
  const { data, error } = await useFetch(url)
  return { data, error }
}


But that only works on client side?! I am confused. What is the recommended way to do that? Maybe like that? https://nuxt.com/docs/guide/recipes/custom-usefetch#custom-usefetch
Nuxt
How to create a custom fetcher for calling your external API in Nuxt 3.
Custom useFetch in Nuxt · Recipes
Was this page helpful?