我在db.js下面的代码片段,如何从不同的Node.js代码
exports.asyncGetAllData = function() {
connection.connect(function(err) {
connection.query(sqlGetAllData, function (err, result) {
if (err) reject(err);
else
{
//console.log(result);
}
});
});
};
获取数据,我想要得到的结果数据,当我在调用的函数app.js如下。您可以看到,当我试图从db.js中获取数据时,它在控制台窗口中显示“数据未定义”。我该如何解决这个问题?任何建议?
由于提前,
看看[这里](https://stackoverflow.com/questions/23339907/returning-a-value-from-callback-function-in-node-js)。 –