How to handle one form but post data to multiple tables?
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
I'm trying to post some form data, some required and some optional, to multiple postgres tables using nextjs15. All the data is coming from one form. I keep getting errors on the server using api routes. Please help.
6 Replies
@Briard show error
Sun bearOP
⨯ [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
code: 'ERR_INVALID_ARG_TYPE'
}
Briard
code?
Sun bearOP
i removed it and started from scratch:
import { auth, currentUser } from "@clerk/nextjs/server";
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
try {
const body = await req.json();
const user = await currentUser();
if (!user?.id) {
return new NextResponse("Unauthorized", { status: 401 });
}
auth.protect();
console.log(body);
return NextResponse.json(body);
} catch (error) {
console.log(error);
return new NextResponse("Internal Server Error", { status: 500 });
}
}
i believe this was the code before:
@Briard code?
Sun bearOP
|