I\'m getting two very weird results trying to make some basic GET calls with Meteor\'s HTTP library.
These same requests work fine with Curl and python, so it\'s not
Confusing sync and async (particularly with HTTP
) is a really common mistake with meteor. Here's the rule: If you want to get the result back out of the method, use a synchronous call. See this section of the docs for an example. Your implementation should look something like:
Meteor.methods({
getEmails: function (authId, threadId) {
check(authId, String);
check(threadId, String);
try {
// note that options is a single object
var options = {auth: authId, params: {id:threadId};
var result = HTTP.get("https://api.nylas.com/threads", options);
// this is just a guess - you should log the result to find
// out what parts you need to extract
return result.data;
} catch (e) {
// something bad happened
return false;
}
}});
On the client you'll do something like this:
Meteor.call('getEmails', authId, threadId, function(err, result) {
return console.log(result);
});
Note:
options
must be a single argument. You were passing two values for options, but the HTTP.get
methods assumes it's 3rd argument is a callback. In your case it was an object, and thus the errors.server
directory or wrap it in an isServer block.Your API request is receiving a 401 unauthorized challenge response.
You may need to proxy your request to avoid the challenge.