Skip to content

Commit a322a33

Browse files
committed
👕 ref(api): car endpoint
1 parent 9c64020 commit a322a33

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

server/api/car/[id].get.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import cars from "@/data/cars.json";
1+
import { PrismaClient } from "@prisma/client";
22

3-
export default defineEventHandler((event) => {
3+
const prisma = new PrismaClient();
4+
5+
export default defineEventHandler(async (event) => {
46
const { id } = event.context.params;
57

6-
const car = cars.find((car) => car.id === parseInt(id));
8+
const car = await prisma.car.findUnique({
9+
where: {
10+
id: parseInt(id),
11+
},
12+
});
713

814
if (!car) {
915
throw createError({

0 commit comments

Comments
 (0)