i have a Simple Query in node.js. But i can not handle the error or empty. I have tried:
isempty, =="", =="undefined"
con.query("SELECT id FROM users WHERE secretkey = '"+connection_on_obj.secretkey+"' AND id = '"+connection_on_obj.userid+"' LIMIT 1", function (err, result, fields) { if(err) { console.log("ERROR"); }else{ if(result[0].id) { console.log("OK"); }else{ console.log("NO USER"); } } });
I become in the most cases the error: Cannot read property 'id' of undefined