Reputation: 931
Here's the method located in server\twitter\methods.js
Meteor.startup(function(){
Meteor.methods({
searchTweets:function(term){
T.get('search/tweets', { q: term, count: 2 }, function(err, data) {
console.log(data);
return data;
})
}
});
});
Here's the event code located in client\search.js
Template.DashboardSearch.events({
"click #btnSearchTweets": function(event, template){
event.preventDefault();
var term = $('#searchTerm').val();
Meteor.call('searchTweets', term, function(err, result) {
console.log(err);
console.log(result);
if (err) {
console.log(err);
}
if (result) {
Session.set('tweetData', result);
}
});
$('#searchTerm').val("");
}
});
The thing is, the 2 console.log()
statements in the search.js file both return undefined
while the console.log()
in methods.js returns the expected twitter api data, any clues?
Upvotes: 1
Views: 125
Reputation: 931
I might've mislead some people with how I framed my question.
The thing is; I was using the meteorhacks:npm package & the T
represent a Meteor.npmRequire()
package.
This is how my method looks like now:
Meteor.methods({
searchTweets:function(term){
var tweets = Async.runSync(function(done) {
T.get('search/tweets', { q: term, count: 2 }, function(err, data) {
done(null, data);
});
});
return tweets.result;
}
});
Everything seems to be working correctly now.
Upvotes: 1