Portgas D. Miang
PPrisma
•Created by Portgas D. Miang on 6/22/2024 in #help-and-questions
Invalid `prisma.course.create()` invocation:
i have this error when i create a schema in next js 14:
import { NextResponse } from "next/server";
import { auth } from "@clerk/nextjs/server";
import { db } from "src/lib/db";
export async function POST(req: Request) {
const { userId } = auth();
try { const { courseTitle } = await req.json(); if (!userId) { return new NextResponse("Unauthorized", { status: 401 }); } const course = await db.course.create({ data: { userId: userId, courseName: courseTitle, typeCourse: "default" } }); console.log({ course }); return NextResponse.json(course); } catch (e: any) { console.log(e); return new NextResponse("Error creating course", { status: 500 }); } } ------------------ ERROR ------------------------
try { const { courseTitle } = await req.json(); if (!userId) { return new NextResponse("Unauthorized", { status: 401 }); } const course = await db.course.create({ data: { userId: userId, courseName: courseTitle, typeCourse: "default" } }); console.log({ course }); return NextResponse.json(course); } catch (e: any) { console.log(e); return new NextResponse("Error creating course", { status: 500 }); } } ------------------ ERROR ------------------------
4 replies