Running into a bit of an odd issue. I'm using sveltekit and prisma with postgres. I'm loading data like so in my +page.server.ts file:
import type { PageServerLoad } from "./$types"
import { prisma } from "$lib/server/prisma"
export const load = (async () => {
const response = {
companies: await prisma.companies.findMany(),
barges: await prisma.barges.findMany(),
parish_tax: await prisma.parish_tax.findMany()
}
return { feed: response };
}) satisfies PageServerLoad;
The companies and barges tables load fine. The parish_tax portion throws the following error:
Error: Data returned from `load` while rendering /dashboard is not serializable: Cannot stringify arbitrary non-POJOs (data.feed.parish_tax[0].parish_rate)
Here are my table columns:
companies
parish_tax
Trying to understand why I'm receiving this error, if anyone could help.
Thanks!
You are supposed to only return POJOs (plain-old-javascript-objects) from the load function in SvelteKit.
Your response data is not serializable, because your parish_tax
objects contain an attribute parish_rate
which is not a POJO and therefore non serializable. I am not sure what the exact type of the parish_rate
attribute is, my guess is probably a class which can not be serialized. The solution is to simply cast this attribute to a type which is serializable before returning it from the load function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With