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