xeon06X
tRPC4y ago
21 replies
xeon06

input needs to be an object when doing a batch call?

Hey folks, just setup tRPC and running into the above error when trying to run mutations. Queries, even with inputs, work fine. Am I doing something wrong?

// Router
export default router({
  submit: procedure
    .input(
      z.object({
        foo: z.string(),
      })
    )
    .mutation(({ input }) => {
      console.log(input)
      return "helloooo"
    }),
})

// Component
const submit = trpc.submit.useMutation()

submit
  .mutateAsync({ foo: "bar" })
  .then((data) => console.log(data))
Was this page helpful?