T
tRPC

Multiple Inputs on TRPC Procedure?

Multiple Inputs on TRPC Procedure?

Jjackhammer82347/15/2023
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
Wwleistra7/16/2023
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.

Looking for more? Join the community!

T
tRPC

Multiple Inputs on TRPC Procedure?

Join Server