Passing a object with readonly attributes through tRPC
I have a class (provided by a library)
I want to send this / the data of the readonly attributes to the client, but either while sending it directly or while destructing the object everything get's prefixed with and underscore (because it is private and readonly I think ?). The problem is if I try to access this data on the client Typescript will throw an error because the attribute is "private".
How can I clone this data and or send it so that I can access it on the client ?
4 Replies
https://www.jsonrpc.org/specification
you can generally only transmit json
with a transformer like superjson you can also transmit some other stuff like dates
So do I have to manually type out something like ?:
And then send this object
id probably stick a method on the object that gives you something you can send
if you're already doing oop anyway
The object is created by a library so nothing much I can do there, I'll probably write some helper functions so I can create something send able, thanks for the help though.