node async ,parallel waterfall 异步方法
function football_index(res, postData) { console.log('football_index start', postData); async.parallel({ caiqiu_focus_02: function(cb) { request.post({ url: 'http://api.caiqr.com/api', form: { 'cmd': 'caiqiu_focus_02', 'gzip': '0', } }, function(err, response, body) { if(!err){ cb(null,JSON.parse(body)); } }) }, football_home_02: function(cb) { request.post({ url: 'http://api.caiqr.com/api', form: { 'cmd': 'football_home_02', 'gzip': '0', } }, function(err, response, body) { if(!err){ cb(null,JSON.parse(body)); } }); } }, function(err, results) { if (err) { console.error(err); } else { var locals = { 'caiqiu_focus_02': results.caiqiu_focus_02, 'football_home_02': results.football_home_02 }; console.log('locals 数据',JSON.stringify(locals)); var options = { pretty: true }; var fn = jade.compileFile('../view/template/index.jade', options); var html = fn(locals); nodeconfig.httpHeadSettingHTML(res); res.end(html); } }); }