I have tried to fix this bug for a while now and I literally do not know what to search for anymore. I don't know if it is a bug with the T3 stack as a whole or just TRPC. On my user profiles I have a createdAt field which is supposed to be a datetime field. I want to prefetch this in my user profile page.
await ssg.profile.getByIdPrivate.prefetch({ userId: session.user.id, }); console.log("getServerSideProps prefetchResult", ssg.dehydrate()); // to inspect prefetch result
return { props: { trpcState: ssg.dehydrate(), userId: session.user.id, username: session.user.name, } as const, }; }; if I don't use superjson I get this error Error: Error serializing
.trpcState.queries[0].state.data.createdAt
.trpcState.queries[0].state.data.createdAt
returned from
getServerSideProps
getServerSideProps
in "/profile". Reason:
object
object
("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types.
But if I do my server side prefetching does't work. I hit the loading state in my query It seems to me that this is a issue relating to superjson not working properly. I don't know how to fix it anymore