Dawson
Dawson3mo ago

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
No description
No description
Solution:
``` const t = initTRPC.context<Context>().create({ transformer: superjson, errorFormatter({ shape, error }) { return {...
Jump to solution
4 Replies
Dawson
DawsonOP3mo ago
"use client";

import { useTRPC } from "@/utils/trpc";
import { useQuery } from "@tanstack/react-query";

export default function Test() {
const trpc = useTRPC();

const response = useQuery(trpc.server.getServers.queryOptions());

return <div>{JSON.stringify(response.data)}</div>;
}
"use client";

import { useTRPC } from "@/utils/trpc";
import { useQuery } from "@tanstack/react-query";

export default function Test() {
const trpc = useTRPC();

const response = useQuery(trpc.server.getServers.queryOptions());

return <div>{JSON.stringify(response.data)}</div>;
}
is the code im using
Dawson
DawsonOP3mo ago
LearnSpigot: Send and save code snippets on our pastebin
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
Solution
Dawson
Dawson3mo ago
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,
},
};
},
});
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,
},
};
},
});
Dawson
DawsonOP3mo ago
this fixed it

Did you find this page helpful?