#Can somebody tell me where I find the
1 messages · Page 1 of 1 (latest)
The reason why I ask is because this function is able to serialize values like Date() and undefined, so I'd also like to use it within getServerSideProps
it should use the same implementation as mentioned in web mdn
hmmm, that's weird
then maybe it's not the function, but prisma that is serializing Date() for me?
there you have it
because in an api, all I'm doing is pass a prisma response to this function and it serializes it just fine
are you sure it is serialised just fine? because im pretty sure it becomes a string on the client
JSON.parse(JSON.stringify(new Date())) doesnt work
like you expect it to
well, in getServerSideProps, it can't even be serialized to this string
are you fetching your own api routes inside gssp?
I was just thinking to use the same function in getServerSideProps to get over this hurdle
no
I'm querying prisma
then idek what you are asking
the source code of NextRresponse.json is in the link above
I'm just trying to avoid writing an own serializer for gssp, when there already seems to be one in Next.js
yeah, that's exactly my problem
yes, so you need to find a way to serialise it because
there already seems to be one in Next.js
there isnt any built-in
what I'm saying is: I have an api, where i am querying an object that I got from prisma, and I use it like so: res.status(200).json(observation)
this works perfectly fine, no complaints about serialization
when i query the same object in gssp with the same prisma query and pass it to props, i get the serialization error
so what I'd like to do is the same thing that happens in the api
return { props: JSON.parse(JSON.stringify(props)) }
because there isn't a serialisability check
unlike gssp which has isSerializable()
but that doesnt change the fact that it is not serialisable
ah
if you are fine with your dates becoming string then use this
so what I'm doing in the API is basically already wrong, but there is no check against it