Add routes to get location and sensor by name
Added viewdata using chart.js
This commit is contained in:
@ -2,6 +2,7 @@ const {
|
||||
addLocation,
|
||||
getLocation,
|
||||
getLocationById,
|
||||
getLocationByName,
|
||||
updateLocation,
|
||||
deleteLocation,
|
||||
} = require("../functions/location");
|
||||
@ -58,6 +59,19 @@ router.delete("/delete", async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
//get location by name
|
||||
router.get("/name/:name", async (req, res, next) => {
|
||||
try {
|
||||
//get params
|
||||
const { name } = req.params;
|
||||
const location = await getLocationByName(name);
|
||||
res.status(200).json(location);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//get location by id
|
||||
|
Reference in New Issue
Block a user