diff --git a/app/src/building.js b/app/src/building.js index c4419b39..c5c497aa 100644 --- a/app/src/building.js +++ b/app/src/building.js @@ -40,7 +40,13 @@ function queryBuildingsAtPoint(lng, lat) { function queryBuildingsByReference(key, id) { if (key === 'toid'){ return db.manyOrNone( - "SELECT * FROM buildings WHERE b.ref_toid = $1", + `SELECT + * + FROM + buildings + WHERE + ref_toid = $1 + `, [id] ).catch(function(error){ console.error(error); @@ -49,8 +55,10 @@ function queryBuildingsByReference(key, id) { } if (key === 'uprn') { return db.manyOrNone( - `SELECT b.* - FROM buildings as b, building_properties as p + `SELECT + b.* + FROM + buildings as b, building_properties as p WHERE b.building_id = p.building_id AND diff --git a/app/src/server.js b/app/src/server.js index bba854b9..dd2f3028 100644 --- a/app/src/server.js +++ b/app/src/server.js @@ -177,11 +177,7 @@ server.route('/building/:building_id.json') .get(function (req, res) { const { building_id } = req.params; getBuildingById(building_id).then(function(result){ - if (result && result.length) { - res.send(result) - } else { - res.status(404).send({error:'Not Found'}) - } + res.send(result); }).catch(function(error){ console.error(error); res.send({error:'Database error'})