Meteor.call callback doesn't fire in AutoForm onSuccess hook


#1

Trying to call a server method from inside an AutoForm onSuccess hook. The method gets executed on the server (base64String gets logged to the server), but the client side callback never fires - none of the client side console.log’s show up in the browser console, so the client never gets back an error or a response.

If I move the identical Meteor.call to a Template event (say a “click” event on the submit button), the callback fires.

I have also tried the Meteor.call in a meteor-collection-hooks after.insert hook, but the callback doesn’t fire there either.

Have tried wrapping the Meteor.call in an immediate setTimeout with no change.

What am I doing wrong?

server.js

Meteor.methods({
  'generate_pdf': function() {
     <...do some stuff that generates a PDF as a base64 string...>
     console.log(base64String);
     return base64String;
  }
},

client.js

AutoForm.hooks({
  testForm: {
    onSuccess: function(formType, result) {
      Meteor.call('generate_pdf'), function(err, res) {
        console.log("In the callback");
        if (err) {
          console.log(err);
        } else if (res) {
           console.log(res);
        }
      }      
    }
  }
});

#2

Whoops…Had an extra close paren in the Meteor.call, so the callback wasn’t getting passed to the call.