#Can somebody tell me where I find the

1 messages · Page 1 of 1 (latest)

slender burrow
#

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

narrow kettle
#

it should use the same implementation as mentioned in web mdn

slender burrow
#

hmmm, that's weird

slender burrow
#

then maybe it's not the function, but prisma that is serializing Date() for me?

stark tree
#

there you have it

slender burrow
#

because in an api, all I'm doing is pass a prisma response to this function and it serializes it just fine

stark tree
#

JSON.parse(JSON.stringify(new Date())) doesnt work

#

like you expect it to

slender burrow
#

well, in getServerSideProps, it can't even be serialized to this string

stark tree
#

are you fetching your own api routes inside gssp?

slender burrow
#

I was just thinking to use the same function in getServerSideProps to get over this hurdle

#

no

#

I'm querying prisma

stark tree
#

then idek what you are asking

#

the source code of NextRresponse.json is in the link above

slender burrow
#

I'm just trying to avoid writing an own serializer for gssp, when there already seems to be one in Next.js

stark tree
#

there you have your answer

slender burrow
#

yeah, that's exactly my problem

stark tree
#

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

slender burrow
#

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

stark tree
stark tree
#

unlike gssp which has isSerializable()

#

but that doesnt change the fact that it is not serialisable

slender burrow
#

ah

stark tree
slender burrow
#

so what I'm doing in the API is basically already wrong, but there is no check against it

stark tree
#

yes, there isnt any check

#

the date comes back as string

slender burrow
#

yeah, this is fine, but still, I should probably implement my own serializer and use it both in the api and in gssp

#

thanks a lot