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.3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
This is how TanStack Query works, data may initially be loading.
Oh ok. Do I need to follow that model at all times while using Start? I'm still new to the whole TanX world so I'm not sure what's assumed tied in or not (Query for example being a part of the Convex piece).
If I need to make multiple queries to populate different parts of my page, what's the strategy there since useSuspendedQuery returns a data and I need to refer to them uniquely? Or do I need to return everything I might need in one query? I don't need reactivity in this case if that helps. DISREGARD - sorry, still finding the line between platform specific stuff and react/JSX. I think I got it.