From e5442367f1727d6659078783588554881ae324b6 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 3 Jul 2024 17:48:39 -0400 Subject: [PATCH] Give a 404 from measurements endpoint if student doesn't exist. --- src/stories/hubbles_law/router.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stories/hubbles_law/router.ts b/src/stories/hubbles_law/router.ts index 7d6c2eb..a6db5b3 100644 --- a/src/stories/hubbles_law/router.ts +++ b/src/stories/hubbles_law/router.ts @@ -188,7 +188,10 @@ router.delete("/sample-measurement/:studentID/:measurementNumber", async (req, r router.get("/measurements/:studentID", async (req, res) => { const params = req.params; const studentID = parseInt(params.studentID); - const measurements = await getStudentHubbleMeasurements(studentID); + const student = await findStudentById(studentID); + const measurements = student !== null ? + await getStudentHubbleMeasurements(studentID) : + null; const status = measurements === null ? 404 : 200; res.status(status).json({ student_id: studentID,