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
barry15mo ago
mutation not query
sommeeeR
sommeeeROP15mo 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
barry15mo ago
semantics really doesnt matter what you use either for
sommeeeR
sommeeeROP15mo ago
alright which should i use then?
barry
barry15mo ago
mutation is the easy choice here, just works
sommeeeR
sommeeeROP15mo ago
ok ill go for that then
Want results from more Discord servers?
Add your server