Corbi-Wan KenobiC
Convex Community11mo ago
4 replies
Corbi-Wan Kenobi

useQuery giving undefined while useSuspenseQuery gives results

Using TanStack Start. Here is the query.

export const getDeviceTypes = query({ args: {}, handler: async (ctx) => { return await ctx.db .query("device_types") .withIndex("by_categoryId", (q) => q.eq( "categoryId", "kn7bypng5v3mbmn4fnvrfd34r57azdcw" as Id<"deviceCategories">, ), ) .collect(); }, });

When I call it from my tsx page, if I use const { data } = useQuery(convexQuery(api.network.getDeviceTypes, {})); then I get undefined via a console.log. If I use useSuspenseQuery I get the array I expect.

I've also tried const data = useQuery(api.network.getDeviceTypes, {}); which also returns undefined.
Was this page helpful?