SeattleStephens
SeattleStephens

Reputation: 587

$meteor.call Callback not invoked

I'm new to Meteor and have a $meteor.call where the callback is never invoked in spite of the fact that I see the return value in the server Node inspector for the Meteor.method.

client

$meteor.call('login', { url: creds.url, username: creds.user, password: creds.password }, function (err, response) {
  if (err) {
    console.log('login failed');
  } else {
    console.log('login succeeded: ' + response);
    Session.set('ticket', response);
  }
});

server

login: function (data) {
  this.unblock();

  var loginSync = Meteor.makeAsync(HTTP.post); // using workaround for wrapAsync issue #2774
  var postResults = loginSync(url + '/ticket', options);
  console.log('return, status: ' + postResults.data.statusCode + ', ' + postResults.data.content);
  return postResults;

Upvotes: 0

Views: 84

Answers (1)

Luna
Luna

Reputation: 1178

Meteor.call doesn't have $ in the beginning.

From Meteor's docs:

Meteor.call(name, [arg1, arg2...], [asyncCallback])

So your call should look more like:

Meteor.call('methodName', var1, var2, function(error, result){});

Also, are you sure you pass your data to server side correctly? I don't see your variables/rest of your code if there is more.

Upvotes: 1

Related Questions