Just like in the previous section, we will need to start by adding the APIs to get the readings and their average for a certain time period:
app.get('/temperature/range', function (req, res) { /** * Here, the "start" and "end" datetimes for the range of readings are * expected to be received through the query parameters. This is spllied as part * of the URL request */ const {start, end} = req.query /** * The "fetchReadingsBetweenTime" method is called, which returns an array of results, which we return as JSON to the client side */ databaseOperations.fetchReadingsBetweenTime ('temperature', start, end, (err, results) => { if (err) { console.error(err) return res.status(500).end() } res.json(results) }) }) app.get ...