在服务器代码中,我无法在客户端的Meteor.call
错误回调中得到错误,内部发生错误Meteor.bindEnvironment
。下面是要复制的示例代码
在服务器
Meteor.methods({
customMethod: function(arg1, arg2){
Stripe.customers.create({
email: "email@here.com,
description: "blah blah",
source: token,
metadata: {
planId: planId,
quantity: n
},
plan: planId,
quantity: n
}, Meteor.bindEnvironment(function (err, customer) {
if(err){
console.log("error", err);
// TODO cannot catch this error on the client
throw new Meteor.Error(err.rawType, err.message)
}
}))
}
})
在 Meteor 事件中的客户端中,
Meteor.call('customMethod', arg1, arg2, function (err, resp) {
if(err){
Session.set('some-error', err)
}
if(resp){
// TODO cannot catch errors throwing from the server
// when inside Meteor.bindEnvironment
Session.set('some-success', true)
}
});
会话变量永远不会设置。任何帮助都会很棒。谢谢!