fix: voting
deskripsi - fix get user id di ssr menjadi di client
This commit is contained in:
27
src/app/api/voting/[id]/daftar-pilihan/route.ts
Normal file
27
src/app/api/voting/[id]/daftar-pilihan/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const { id } = params;
|
||||
try {
|
||||
const data = await prisma.voting_DaftarNamaVote.findMany({
|
||||
where: {
|
||||
votingId: id,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: data },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user