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)

enter image description here

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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -