DawsonD
tRPC7mo ago
Dawson

Network request was successful, variable was not populated

I'm fetching the data, json is being returned, but trying to use this data is impossible
image.png
image.png
Solution
const t = initTRPC.context<Context>().create({
  transformer: superjson,
  errorFormatter({ shape, error }) {
    return {
      ...shape,
      data: {
        ...shape.data,
        zodError:
          error.cause instanceof ZodError ? error.cause.flatten() : null,
      },
    };
  },
});
Was this page helpful?