Hello there.
Using aldeed Autoform, I intend to send a HTTP.call request before the collection is inserted on database. I have the following code
// client Code
// Autoform routines to call API before insert hook
var techMapBeforeHook = {
before: {
insert: function(doc,template){
Meteor.call('sendDocToAPI', doc, function(error, success) {
if (error) {
console.log('error', error);
}
if (success) {
console.log("It worked!");
// return doc; This does not work
// return this.result(doc); This does not work either
}
return this.result(doc); // This works. But I expected it worked if the call worked, inside the if(success).
});
}
}
}
// Server Code
Meteor.methods({
sendDocToAPI: function(doc) {
console.log(doc);
return doc;
}
});
I believe I am missing some scope clarity here. Why the this.result(doc) does not work inside the success block?
Thanks for your time.