⨯ Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Com
Unanswered
Bombay posted this in #help-forum
BombayOP
my internal
⨯ Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
my "actions.ts"
"use server";
import { db } from "@/lib/kysely";
interface store {
sid: string;
store_type: string;
name: string;
lat: number;
long: number;
}
export async function createStore({ sid, store_type, name, lat, long }: store) {
try {
const store = await db
.selectFrom("Store")
.select(["Store.sid", "Store.store_type"])
.where("Store.sid", "=", sid)
.where("Store.store_type", "=", store_type)
.executeTakeFirst();
if (store) {
throw Error(
}
const cs = await db
.insertInto("Store")
.values({
sid: sid,
store_type: store_type,
name: name,
lat: lat,
long: long,
})
.executeTakeFirst();
return cs;
} catch (e) {
console.error(e);
throw Error(
}
}
⨯ Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
my "actions.ts"
"use server";
import { db } from "@/lib/kysely";
interface store {
sid: string;
store_type: string;
name: string;
lat: number;
long: number;
}
export async function createStore({ sid, store_type, name, lat, long }: store) {
try {
const store = await db
.selectFrom("Store")
.select(["Store.sid", "Store.store_type"])
.where("Store.sid", "=", sid)
.where("Store.store_type", "=", store_type)
.executeTakeFirst();
if (store) {
throw Error(
${sid}${store_type}_duplicate);}
const cs = await db
.insertInto("Store")
.values({
sid: sid,
store_type: store_type,
name: name,
lat: lat,
long: long,
})
.executeTakeFirst();
return cs;
} catch (e) {
console.error(e);
throw Error(
_duplicate);}
}
1 Reply
I do not think you can pass objects to server components from the client, a way to bypass this is to stringify your json object and then send it to your server action, then on the server action convert the string into an object.