我有以下代码。我对nodejs和JS比较陌生
我想获取%1中的值。但我没有被定义。只有2个。日志输出到日志。
我从回调和https://github.com/felixge/node-mysql中读取了nodeJS返回值,但没有关于返回值的示例。
我不知道如何在node-mysql页面中给出的示例中使用return语句。exports.location_internal = function (req, res) {
var r = getExternalLocation(2);
// 1. log
console.log(r);
res.send( r);
}
var getExternalLocation = function (id) {
pool.getConnection(function(err, connection){
if(err) throw err;
var response = {};
connection.query( "select * from external_geo_units where geo_unit_id = "+id, function(err, rows){
if(err) throw err;
response.data= rows;
// 2. log
console.log(response);
return response;
});
connection.release();
});
};