How can I useQuery when I click a button

I have this privateProcedure on the backend. I want to call it when I hit a button in my frontend:
checkDate: protectedProcedure
.input(z.object({ date: z.date() }))
.query(({ input, ctx }) => {
return {
message: 'hello world ' + input.date.toISOString(),
};
}),
checkDate: protectedProcedure
.input(z.object({ date: z.date() }))
.query(({ input, ctx }) => {
return {
message: 'hello world ' + input.date.toISOString(),
};
}),
How do I do that? I am btw gonna query a database for that date, and return something. I just simplified it for this example
6 Replies
barry
barry13mo ago
mutation not query
sommeeer
sommeeer13mo ago
i thought mutation was for when you needed to change something? all i want to do is fetch something if it contains the date i pass in
barry
barry13mo ago
semantics really doesnt matter what you use either for
sommeeer
sommeeer13mo ago
alright which should i use then?
barry
barry13mo ago
mutation is the easy choice here, just works
sommeeer
sommeeer13mo ago
ok ill go for that then
Want results from more Discord servers?
Add your server