javascript - How to check throw error on response in node js when my query result rowCount is 0 -
if rowcount o need send on res failed. if rowcount 1 need send res status success. kindly me out. when tried take print (client.query) coming json(result on attached image)
var query = client.query("select * pp_user_profile email_id = '"+req.query.email_id+"' , user_password= '"+req.query.user_password+"'"); console.log(client.query); query.on("end", function (result) { if (result.length > 0) { if (result) console.log("test:" + result); res.write('failed'); } else{ console.log(result); client.end(); res.writehead(200, {'content-type': 'text/plain'}); res.write('success'); res.end(); }
change if...else condition way.
if(result.rowcount === 1){ // code goes here } else{ // code goes here }
Comments
Post a Comment