I am using NextJS and Supabase and this is the error that it shows:
⨯ 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. at stringify () digest: "1376061893"
app/api/Orders/route.ts:
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
import { NextApiRequest, NextApiResponse } from "next";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
export async function GET (request: NextApiRequest) {
const cookieStore = cookies()
const supabase : any = createServerComponentClient({ cookies: () => cookieStore })
const {data: {session }} = await supabase.auth.getSession();
const {data, error } = await supabase
.from('orders')
.select()
.eq('id', session?.user.id)
if (error == null) {
return NextResponse.json({ data });
}
return NextResponse.json({ error: error.message });
}```
Calling it here: components/Orders/ViewOrders.tsx:
```ts
import OrderList from "./OrderList";
export default async function ViewOrdersByWaterStation({}) {
try{
const response = await fetch(`http://localhost:3000/api/Orders`,{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
const data = await response.json()
return Response.json({ data })
}catch(err){
console.log(err)
}
return (
<div>
<OrderList orders={orders} />
</div>
);
}```