Convex api not working and causing problem in user validations from the convex tables
// to return all spaces present in the current project
export const get = query({
args: {},
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Not authenticated");
}
const userId = identity.subject;
return await ctx.db
.query("spaces")
.filter(q => q.eq(q.field("userId"), userId))
.collect();
}
});
and the way I am calling it to check whether the user is exists or not
import { useQuery } from "convex/react";
import { api } from "@convex/_generated/api";
export const useGetSpaces = () => {
const data = useQuery(api.spaces.get);
const isLoading = data === undefined;
return {data, isLoading}
}
the {api} API i import from _generated/api from convex is causing error, would like to get some advice on how to resolve this issue and I would like to point out that we are using clerk for authentication.


