tRPCttRPC
Powered by
epistolE
tRPCโ€ข3y agoโ€ข
2 replies
epistol

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
trpc/examples/fastify-server at main ยท trpc/trpc
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Using superjson transformer makes data empty
MartinMMartin / โ“-help
17mo ago
trpc 11 superjson transformer not working with unstable_httpBatchStreamLink
NeatZNNeatZ / โ“-help
13mo ago