is there a way to call server function using useQuery hook

e.g

filename.ts
"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;
};


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 ๐Ÿ™
Was this page helpful?