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);
                  }
           });
    }
    

      

  • 相关阅读:
    并发编程(线程)
    并发编程(进程)
    并发编程(操作系统的介绍)
    模块与包
    网络编程
    Django项目的创建与管理和pycharm与Github的秘密
    python解释器配置和python常用快捷键
    代码的调试.运行
    57. 三数之和
    1347. 尾随零
  • 原文地址:https://www.cnblogs.com/zerohu/p/6340416.html
Copyright © 2011-2022 走看看