We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9c64020 commit a322a33Copy full SHA for a322a33
server/api/car/[id].get.js
@@ -1,9 +1,15 @@
1
-import cars from "@/data/cars.json";
+import { PrismaClient } from "@prisma/client";
2
3
-export default defineEventHandler((event) => {
+const prisma = new PrismaClient();
4
+
5
+export default defineEventHandler(async (event) => {
6
const { id } = event.context.params;
7
- const car = cars.find((car) => car.id === parseInt(id));
8
+ const car = await prisma.car.findUnique({
9
+ where: {
10
+ id: parseInt(id),
11
+ },
12
+ });
13
14
if (!car) {
15
throw createError({
0 commit comments