2017-07-05 80 views
1
Promise.map(response.orders.orders, function(order) { 

        if(order.order_destination == "OC"){ 
         return searchOrdersBll.promisifyOrdersOC(order).then(function(order){ 
          return searchOrdersBll.orderCommentHistory(order); 
          }) 
        }else if(order.order_destination == "OB"){ 
         return searchOrdersBll.promisifyOrdersOB(order).then(function(order){ 
          return searchOrdersBll.orderCommentHistory(order);        
          }) 
        }      

       }) 
       .then(function(data) { 
        args.order = data; 
        args.track_orders = []; 
        htmlResponse(req, res, partials.orderedtemplate, args); 
       }) 

越來越問題並未得到回報:警告:承諾是在處理程序創建,但是從它

警告:承諾是在一個處理器在 無功/ www/html等/的CustomerService創建/ server/apps/search/controller/search_bll.js:56:29 ,但未從它返回, 位於Function.Promise.map(/ var/www/html/customerservice/node_modules/bluebird/js/release/map。 js:164:12)

+0

如果你的'htmlResponse'功能是承諾生成器,你應該回到它的結果在容器功能。現在,您的異步調用鏈會將「undefined」結果返回給上一級調用方,從而在該行上制動。 –

回答

1

你只需要ret甕通過htmlResponse返回的承諾:

Promise.map(response.orders.orders, function(order) { 

        if(order.order_destination == "OC"){ 
         return searchOrdersBll.promisifyOrdersOC(order).then(function(order){ 
          return searchOrdersBll.orderCommentHistory(order); 
          }) 
        }else if(order.order_destination == "OB"){ 
         return searchOrdersBll.promisifyOrdersOB(order).then(function(order){ 
          return searchOrdersBll.orderCommentHistory(order);        
          }) 
        }      

       }) 
       .then(function(data) { 
        args.order = data; 
        args.track_orders = []; 
        return htmlResponse(req, res, partials.orderedtemplate, args); 
       }) 
相關問題