【发布时间】:2014-05-21 02:33:09
【问题描述】:
if (Meteor.isClient) {
Template.hello.events({
'click input': function () {
//create a new customer
Meteor.call('createCustomer', function (error, result) {
console.log("Error: " + error + " Result: " + result); } );
}
});
}
if (Meteor.isServer) {
Meteor.methods({
createCustomer: function () {
try {
balanced.configure('MyBalancedPaymentsTestKey');
var customer = Meteor._wrapAsync(balanced.marketplace.customers.create());
var callCustomer = customer();
var returnThis = console.log(JSON.stringify(callCustomer, false, 4));
return returnThis;
} catch (e) {
console.log(e);
var caughtFault = JSON.stringify(e, false, 4);
}
return caughtFault;
}
});
}
我只是使用了默认的 hello world,没有问候线。
<head>
<title>testCase</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<h1>Hello World!</h1>
<input type="button" value="Click" />
</template>
在客户端打印日志
Error: undefined Result: {}
在服务器端打印日志
[TypeError: Object [object Promise] has no method 'apply']
知道如何等待该承诺而不是返回空白结果吗?
【问题讨论】:
-
更新此行
var customer = Meteor._wrapAsync(balanced.marketplace.customer.create)();