T
TanStack2y ago
dependent-tan

is there a way to call server function using useQuery hook

e.g filename.ts
"use server"
export async function callApi () {
return request("...")
}
"use server"
export async function callApi () {
return request("...")
}
hook.ts
import { callApi } from "./filename"

export const useApi = () => {
const response = useQuery({
queryKey: ["key"],
queryFn: async () => callApi(),
});
return response;
};
import { callApi } from "./filename"

export const useApi = () => {
const response = useQuery({
queryKey: ["key"],
queryFn: async () => callApi(),
});
return response;
};
this way doesn't work. and when inspect network request i see all request details any help how to handle this right ! thanks in advance 🙏
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?