xeon06
xeon06
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
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))
// 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))
13 replies
TtRPC
Created by xeon06 on 1/6/2023 in #❓-help
Using `fetchRequestHandler` with other routes?
Hey everyone, I'm trying to use the fetchRequestHandler with a HatTip server, but all the examples seem to give tRPC entire control of all server responses. I actually want to serve other things besides tRPC routes. Anyone know how I could go about this? So far I've tried this, as well as changing the endpoint to "/" and "". Always the same result, 404s on /trpc
app.use("/trpc", ({ request }) =>
fetchRequestHandler({
endpoint: "/trpc",
req: request,
router: appRouter,
createContext,
})
)
app.use("/trpc", ({ request }) =>
fetchRequestHandler({
endpoint: "/trpc",
req: request,
router: appRouter,
createContext,
})
)
2 replies