this question has answer here:
- how return response asynchronous call? 21 answers
why never true returned? given name exists in array rows , if(rows[i].username == name) gets triggert, why won't function return true?
function existuser(name){ var result = false; ootw.mysql.query('select * time',function(err,rows){ if(err) throw err; (var = 0; < rows.length; i++) { if (rows[i].username == name) { result = true; } }; }); console.log(result); return result; }
your query executes asynchronously, long after result returned.
Comments
Post a Comment