Figuring out REST functionality for Nuxt.js

This commit is contained in:
shb 2025-06-12 09:46:56 +08:00
parent 52a080e69a
commit 822d5e3ca4
2 changed files with 28 additions and 1 deletions

View File

@ -7,8 +7,11 @@ export default defineEventHandler( async (event) => {
const successMsg = "Hello from the backend";
const folders = await prisma.cabinets.findMany();
return {
status: 200,
message: successMsg
message: successMsg,
folders: folders
};
});

View File

@ -0,0 +1,24 @@
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
export default defineEventHandler( async (event) => {
console.log("This is a test for a POST request to the backend");
// const successMsg = "Hello from the backend";
const body = readBody(event);
if (!body) {
return {
status: 400,
message: "Body was not received"
}
} else {
return {
status: 200,
message: "Body received successfully",
body: body
};
}
});