There is also work needed on the client, which I missed on the first pass. You need a template helper which is able to handle data returned from a method call (which is not reactive). One way is to do something like this:
Unfortunately I have trouble keeping your idea ^^ I do not see how the client side retrieves data . If I test alert ( ’ this.result ') , it is undefined.
When the server-side method returns, the result is available in res in the callback, so if you want to check what’s coming back without a template, you could do this:
OK, well it’s hard for me to debug this without using the Twitter API, but you can improve the chances of isolating the issue by changing your method to catch and return errors on the T.get:
Meteor.methods({
postTweet: function() {
const Twit = require('twit');
const T = new Twit({
consumer_key: 'xxx', // API key
consumer_secret: 'xxx', // API secret
access_token: 'xxx',
access_token_secret: 'xxx'
});
const getTweets = Meteor.wrapAsync(T.get);
// search twitter for all tweets containing the word 'banana' since Nov. 11, 2011
try {
return getTweets('search/tweets', { q: 'banana since:2011-11-11', count: 100 });
} catch (error) {
throw new Meteor.Error(error.name, error.message);
}
}
});
Your client code (with the logging shown earlier) will report the specific error produced by the T.get.