epistol
epistolโ€ข12mo ago

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;
}),
GitHub
trpc/examples/fastify-server at main ยท trpc/trpc
๐Ÿง™โ€โ™€๏ธ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
1 Reply
joseph
josephโ€ข8mo ago
did you ever solve this?