Я использую Meteor, что мне нужно сделать, чтобы дождаться обещания, которое будет возвращено после вызова API?
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;
}
});
}
И я просто использовал привет мир по умолчанию без строки приветствия.
<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']
Любая идея, как я могу ждать этого обещания, а не возвращать пустой результат?