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 on the side of the API.

1. Result not consistent with with result from async callback

I'm using the below code in my meteor methods:

//snip! Meteor methods continued above. getEmails: function(authId, threadId){ result = HTTP.get("https://api.nylas.com/threads", {auth:authId}, function(error, result){ console.log(result); }); return result }

Using chrome developer tools I'm able to examine the returned object.

Object {statusCode: 401, content: "{↵ "message": "Could not verify access credential.",↵ "type": "invalid_request_error"↵}", headers: Object, data: Object}content: "{↵ "message": "Could not verify access credential.",↵ "type": "invalid_request_error"↵}"data: Objectheaders: ObjectstatusCode: 401__proto__: Object

Now here's the weird part: Notice that I also have a console.log in the async callback. That output on the server actually returns the data I would expect to receive from a correct API call!

It's a bit lengthy and personal to post, but it returns a status 200.

2. Using params in the call crashes my server

This is a copy of the code above with a very slight change (including params options).

//snip! Meteor methods continued above. getEmails: function(authId, threadId){ result = HTTP.get("https://api.nylas.com/threads", {params:{id:threadId}}, {auth:authId}, function(error, result){ console.log(result); }); return result }

Making this change completely crashes the Meteor server anytime I call this method.

This is what's printed to the chrome developer tools:

Exception while simulating the effect of invoking 'getEmails' Error: Can't make a blocking HTTP call from the client; callback required.(…) Error: Can't make a blocking HTTP call from the client; callback required.

And here's what I'm seeing on the server:

TypeError: object is not a function W20151110-20:52:42.024(-8)? (STDERR) at packages/http/httpcall_server.js:74:1 W20151110-20:52:42.024(-8)? (STDERR) at packages/underscore/underscore.js:750:1 W20151110-20:52:42.025(-8)? (STDERR) at Request._callback (packages/http/httpcall_server.js:116:1) W20151110-20:52:42.025(-8)? (STDERR) at Request.self.callback (/Users/max/.meteor/packages/http/.1.1.1.murctg++os+web.browser+web.cordova/npm/node_modules/request/request.js:344:22) W20151110-20:52:42.025(-8)? (STDERR) at Request.emit (events.js:98:17) W20151110-20:52:42.025(-8)? (STDERR) at Request.<anonymous> (/Users/max/.meteor/packages/http/.1.1.1.murctg++os+web.browser+web.cordova/npm/node_modules/request/request.js:1239:14) W20151110-20:52:42.026(-8)? (STDERR) at Request.emit (events.js:117:20) W20151110-20:52:42.026(-8)? (STDERR) at IncomingMessage.<anonymous> (/Users/max/.meteor/packages/http/.1.1.1.murctg++os+web.browser+web.cordova/npm/node_modules/request/request.js:1187:12) W20151110-20:52:42.027(-8)? (STDERR) at IncomingMessage.emit (events.js:117:20) W20151110-20:52:42.027(-8)? (STDERR) at _stream_readable.js:944:16

This all seems very basic, so I'm surprised it's not working.

What am I missing that's causing all of these issues?