nodejs函数返回值为undefined,不太明白为什么

2024-11-23 06:19:20
推荐回答(1个)
回答(1):

最后用了promise解决,代码如下:
exports.selectByUsername = selectByUsername;
function selectByUsername(username){
var promise = new Promise(function(resolve){
var sql = "SELECT COUNT(*) count FROM wx_user WHERE username = ?";
var sqlParams = [username];
var count;
co.query(sql,sqlParams,function(err,result){
if(err){