jackhammer823411mo ago

Multiple Inputs on TRPC Procedure?

Essentially I'm trying to pass a cart (array of objects) into a public procedure (doing so fine). I want to add user object to the call too but cannot find any info online about multiple inputs into a procedure. Is anyone able to help please? More info here https://stackoverflow.com/questions/76691553/trpc-multiple-inputs
Stack Overflow
TRPC Multiple Inputs
I have a TRPC public procedure in my NextJS project. Currently one of the methods, I pass in the shopping cart of a customer, which is an array of objects. I want to add the user details in additio...
1 Reply
wleistra11mo ago
Define your input as a an object of which one key is the cart array and the second key in the object is the user details. Something along the lines of procedure.input(z.object({cart: [], user: {...}) if you use zod. If you want to give a possible user object on every call you probably want to have a look at trpc middleware and the context.