From this article
async function asyncFun () {
var value = await Promise
.resolve(1)
.then(x => x * 3)
.then(x => x + 5)
.then(x => x / 2);
return value;
}
Meteor.startup(() => {
asyncFun().then(x => console.log(`x: ${x}`));
// <- 'x: 4'
};
But how would you put asyncFun inside Meteor.method and call it?
Meteor.methods({
async asyncFun () {
var value = await Promise
.resolve(10)
.then(x => x * 3 )
.then(x=> x + 5)
.then(x=> x / 2);
return value;
}
});
Meteor.startup(() => {
asyncFun().then(x => console.log(`x: ${x}`)); <-- now asyncFunc is not defined?
});
As I understand that you need to place functions inside Meteor.methods so that client side can also call it?