zoukankan      html  css  js  c++  java
  • 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);
                  }
           });
    }
    

      

  • 相关阅读:
    Markdown文档示例
    Python网络编程(一)
    JS之客户端检测
    MySQL 多表查询
    MySQL 单表查询
    MySQL 入门
    Python内置方法大全
    010 盒模型
    009 CSS选择器
    008 常用样式
  • 原文地址:https://www.cnblogs.com/zerohu/p/6340416.html
Copyright © 2011-2022 走看看