From fee130a06cc3ea86493f173b3e42623a6db2539a Mon Sep 17 00:00:00 2001 From: Gerardo Marx Date: Thu, 29 Oct 2026 00:18:35 -0600 Subject: [PATCH] testing the latest --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index 63fc8b7..3ef1154 100644 --- a/index.js +++ b/index.js @@ -69,6 +69,21 @@ app.get('/api/measurements', (req, res) => { res.json(measurements); }); +app.get('/api/measurements/latest', (req, res) => { + // Check whether any measurements exist. + if (measurements.length === 0) { + return res.status(404).json({ + error: 'No measurements yet' + }); + } + + // The last array element is the latest submitted measurement. + const latest = measurements[measurements.length - 1]; + + res.json(latest); +}); + + // starting the listening service app.listen(3030, () => { console.log('Server running at http://localhost:3030');