我正在使用express with node for rest api,我需要运行for循环来确定输出json.我的路线文件看起来
var Redis = require('ioredis')
var redis = new Redis({
port: 6379,
host: '127.0.0.1',
family: 4,
password: 'password',
db: 0
});
var Jsonresult = {};
var process = function(lat,lon,dist,unit)
{
Jsonresult.result = 'success';
var vehicle_type = new Array('small','medium');
vehicle_type.forEach(function(vehicle, index, arr)
{
redis.georadius ( vehicle,lat,lon ,dist,unit,'WITHCOORD','WITHDIST',function( ERR , Result )
{
if (ERR)
{
console.log(ERR);
}
Jsonresult[vehicle] = Result;
}) ;
})
return Jsonresult;
}
router.get('/:lat/:lon/:dist/:unit', function(req, res, next) {
var lat = req.params.lat;
var …Run Code Online (Sandbox Code Playgroud)