Skip to content
Discussion options

You must be logged in to vote

As the error says, you can't return non-POJO objects from +page.server.js. That is to say: if it's an object that also has methods/prototype methods on it, you get this error. That's because it's a client/server interaction - the .server* page runs in a Node environment, not a browser environment, and sends data over the network, so of course all it can return is plain JSON.

To quote the docs:

A server-only load function must return data that can be serialized with devalue — anything that can be represented as JSON plus things like BigInt, Date, Map, Set and RegExp, or repeated/cyclical references — so that it can be transported over the network.

Question: why do you think this is not good

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@NormandoHall
Comment options

@infovore
Comment options

@NormandoHall
Comment options

Answer selected by NormandoHall
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants