Hello,
I cannot get the wrapAsync method working, following a very simple code that doesn’t work, anybody can tell what is wrong ?
Meteor.methods({ testMethod: function (var1) { var syncFunc = Meteor.wrapAsync(testAsync); var result = syncFunc(var1);
console.log(result); } });
console.log(result);
} });
function testAsync(myVar){ return 'Var is: ’ + myVar; }
Thanks,
An async function must have a callback with a signature of (error, result) for this to work. So if your “async” function looked like this it should work:
(error, result)
function testAsync(myVar, callback) { callback(null, 'Var is: ' + myVar); }
In which null means “no error”.
null
Awesome, thank you very much !!!