CourseForm backend done

This commit is contained in:
Harshitha Shetty
2024-12-09 07:26:57 +05:30
parent e22727eefd
commit ce73a591c5
9 changed files with 408 additions and 76 deletions

View File

@@ -6,9 +6,10 @@ const router = express.Router();
// Get all faculty members
router.get("/", async (req, res) => {
try {
const faculty = await Faculty.find();
res.json(faculty);
const faculties = await Faculty.find();
res.status(200).json(faculties);
} catch (error) {
console.error("Error fetching faculty members:", error.message);
res.status(500).json({ error: "Failed to fetch faculty members" });
}
});
@@ -20,8 +21,9 @@ router.get("/:id", async (req, res) => {
if (!faculty) {
return res.status(404).json({ error: "Faculty member not found" });
}
res.json(faculty);
res.status(200).json(faculty);
} catch (error) {
console.error("Error fetching faculty member:", error.message);
res.status(500).json({ error: "Failed to fetch faculty member" });
}
});