cmdlib.run_sql(config.ser_dbip, config.ser_dbuser, config.ser_dbpasswd, config.ser_dbport, config.ser_dbname, websql, 'select', function(r) { for (var i = 0; i < r.length; i++) { request.post({ url:'http://' + r[i].game_host + ':' + gop_port, form: { cmd: 105, port: r[i].web_port, gamesite: r[i].game_site } }, function(err,httpResponse,body){ if(httpResponse.statusCode == 200){ console.log(body); send.push(body); }else { send.push({'status': "err"}); } if(send.length == gammee.length){ console.log(send); res.json({'status': send}); } }); } });
将所有结果放在一个数组中 再res