epistol
epistol
TtRPC
Created by epistol on 8/2/2023 in #❓-help
Why transformer: superjson breaks the POST ?
With all the GET request I do there seem to be no error, but as soon as I try sending a POST request, i get the following :
"message": "[\n {\n \"code\": \"invalid_type\",\n \"expected\": \"object\",\n \"received\": \"undefined\",\n \"path\": [],\n \"message\": \"Required\"\n }\n]",
"code": -32600,
"data": {
"code": "BAD_REQUEST",
"httpStatus": 400,
"message": "[\n {\n \"code\": \"invalid_type\",\n \"expected\": \"object\",\n \"received\": \"undefined\",\n \"path\": [],\n \"message\": \"Required\"\n }\n]",
"code": -32600,
"data": {
"code": "BAD_REQUEST",
"httpStatus": 400,
Rocking the https://github.com/trpc/trpc/tree/main/examples/fastify-server with a simple :
create: publicProcedure
.input(z.object({ title: z.string() }))
.mutation(({ input, ctx }) => {
const id = db.posts.length + 1;
const post = { id, ...input };
db.posts.push(post);
return post;
}),
create: publicProcedure
.input(z.object({ title: z.string() }))
.mutation(({ input, ctx }) => {
const id = db.posts.length + 1;
const post = { id, ...input };
db.posts.push(post);
return post;
}),
3 replies