Meteor从客户端到服务器方法调用的同步调用

时间:2015-06-08 03:42:33

标签: meteor

处理流星项目并完全阻止以下问题

  • 客户将商品添加到购物车
  • 点击捕获“点击”事件的“下订单”
  • 在Meteor.call()
  • 下面调用服务器示例代码上的方法
  • 现在在服务器端,该方法调用一些外部API
  • 所以我想等待客户端的响应检查结果并路由到确认页面或显示错误消息。
  • 随着回叫,控制转移到默认/当前页面并重定向确认页面我无法检查交易是否成功
Meteor.call('placeOder', order info, sequence, function(error, result) {
    if(error) {
        if(result) {
            console.log("Could not insert the order for the session  = "
                        + sessid + "Order = " + JSON.stringify(result, null, 4));
        } else {
            console.log("Could not insert the order for the session  = " + sessid );
        }
    } else {        
        Session.set('orderStatus', 'Success');
        Router.go('confirmation',  {UniqueId: result.id});            
    }   
});

非常感谢任何帮助解决。基本上在客户端,我想等待服务器的响应,检查响应并相应地路由。

0 个答案:

没有答案