Connected Backend to frontend

This commit is contained in:
tokslaw7
2025-06-22 15:07:19 -04:00
parent c1e98743ff
commit 5e3d5b38dd
6 changed files with 1074 additions and 74 deletions
+21
View File
@@ -0,0 +1,21 @@
const express = require('express');
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
const apiRouter = express.Router();
apiRouter.get('/data', async (req, res)=> {
try{
const data = await prisma.user.findMany();
return res.json(data);
}catch (error) {
console.log("Error fetching data: ", error);
res.status(500).json({error: "Internal server error"});
}
});
// app.use("/api", apiRouter);
module.exports = apiRouter;