Skip to content

Commit

Permalink
Merge pull request #118 from Carifio24/measurements-no-student-404
Browse files Browse the repository at this point in the history
Give a 404 from measurements endpoint if student doesn't exist
  • Loading branch information
Carifio24 authored Jul 3, 2024
2 parents 1d0f226 + e544236 commit fe30ad8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/stories/hubbles_law/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fe30ad8

Please sign in to comment.