Getting error when using $csrfFetch (nuxt-csurf) inside defineQuery #338
-
|
I have this reusable query, when I need to use import { defineQuery, useQuery } from "@pinia/colada";
export const useProfile = defineQuery(() => {
const { $csrfFetch } = useNuxtApp();
return useQuery({
key: ["profile"],
refetchOnMount: false,
query: async () => {
const res = await $csrfFetch("/api/profiles", {
method: "GET",
});
return res;
},
});
});I'm using this query in a component and a page, however I'm getting an error when I open the page or access the route through the browser (not when navigating using from Nuxt): I tried also putting the
inside: query: async () => {
const res = await $csrfFetch("/api/profiles", {
method: "GET",
});
return res;
},I there any chance that this being executed outside Nuxt context? I'm doing anything wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Jul 23, 2025
Replies: 1 comment 3 replies
-
|
It all depends where you are calling |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Then maybe
$crsfFetchcallsuseCsrforuseRuntimeConfig()and that's where the issue is coming from