adding error if no physician found

This commit is contained in:
Arjun Patel
2018-12-30 23:32:20 -08:00
parent 893d170283
commit dd3175ae5a
+6 -2
View File
@@ -59,8 +59,12 @@ app.get('/physicianloc', function (req, res) {
var query = 'SELECT * FROM physicians WHERE LOWER(first_name)=?' +
'AND LOWER(middle_name)=? AND LOWER(last_name)=?';
connection.query(query, [first, middle, last], function (error, results, fields) {
if (error) throw error;
if (error) console.log(error);
if (results.length === 0) {
return res.status(400).send({
message: 'Physician Not Found!'
});
}
var result = res.status(200).send(results[0]);
connection.release();