So I've been using the twitter API w/MeteorJS and what I'm attempting to do is just display the screen name of the twitter user on the browser. This is what I have done so far:
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;
}
)
}
});
So I call the method 'screenName' from my isClient side. I call it from my client side like this:
var temp = Meteor.call('screenName');
On the server side, its printing out the correct value on console but it is not able to return that value. It keeps displaying undefined.
I am a javascript beginner so I might be making a mistake that I'm not seeing right away so if someone could please help me, I would highly appreciate it.
Thanks!
You need to place a function inside the call to be able to get the return.
Meteor.call(
'screenName',
function(error, result){
if(error){
console.log(error);
} else {
console.log(result);
}
}
);
You can read more in the documentation about the call function: http://docs.meteor.com/#/full/meteor_call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With