Why is <000> returned for Meteor.call () in the client?

So, I'm trying to access twitter's REST API and get the tweet screen name. I feel that my code will be the best explanation:

I call the 'screenName' method from isClient ():

  'click button': function () { Meteor.call('screenName', function(error,result) { if (error) { console.log(error); } else { window.alert(result); } } ) } 

And for some reason, the method returns undefined when it actually registers the screen name of the twitter account on the console.

 Meteor.methods({ 'screenName': function() { T.get('search/tweets', { q:'#UCLA', count:1 }, function(err,data,response) { console.log(data.statuses[0].user.screen_name); return data.statuses[0].user.screen_name; } ) } 

If anyone can help me with this. Thank you very much!

0
source share
2 answers

Your server-side method must be synchronous. The method callback returns after the method has already returned undefined . I would like to be more specific, but I'm not sure which library you are using.

You can feel it by looking at examples from HTTP.call . Your code might look something like this:

 Tget = Meteor.wrapAsync(T.get); Meteor.methods({ 'screenName': function() { try { var result = Tget('search/tweets', {q:'#UCLA', count:1}); return result.statuses[0].user.screen_name; } catch (e) { return false; } } }); 

For more on wrapAsync see docs .

+1
source

You are returning data.statuses[0].user.screen_name from your internal function. You need to return it from your screenName method screenName that it is available in Meteor.call() .

0
source