NuxtN
Nuxtβ€’8mo agoβ€’
4 replies
dmarr

[useAsyncData] handler must be a function.

I am trying to write an api utility function that wraps useAsyncData. I don't know if that idea is fraught with peril to begin with, but I am running up against an issue since this function is running in a utility within a setup store in pinia.
The error I get running the following code:

const { data } = await nuxtApp.runWithContext(() => {
  const fetch = useRequestFetch();
  return useAsyncData(apiName, () => fetch(url, { query: searchParams, signal }));
});
setApiSuccess(apiName, data.value);

Throws the
[useAsyncData] handler must be a function.
error. Is there something I can do around this?
Was this page helpful?