0

I have a meteor method which uses HTTP.get to make a request to an API. From what I understood from the docs I can provide options with a headers object to set various things like Content-Type. I've tried this with the following code:

var r = HTTP.call("GET", apiUrl, { headers: { "Content-Type": "application/json" } });
console.log(r);

But this doesn't seem to work, the content type is till "text", see output below:

I20160302-13:50:22.706(0)?   headers: 
I20160302-13:50:22.706(0)?    { 'access-control-allow-headers': 'Content-Type, api_key, Authorization',
I20160302-13:50:22.707(0)?      'access-control-allow-methods': 'GET',
I20160302-13:50:22.707(0)?      'access-control-allow-origin': '*',
I20160302-13:50:22.707(0)?      'content-type': 'text/plain; charset=utf-8',
I20160302-13:50:22.707(0)?      date: 'Wed, 02 Mar 2016 13:50:20 GMT',
I20160302-13:50:22.707(0)?      server: 'nginx/1.6.2',
I20160302-13:50:22.707(0)?      'content-length': '267',
I20160302-13:50:22.707(0)?      connection: 'keep-alive' },

I've tried switching this about using "content-type" and "Content-Type". I've also tried using the shortened HTTP.get function

digitalWestie
  • 2,647
  • 6
  • 28
  • 45
  • 1
    This isn't exactly a duplicate, but see [this question](http://stackoverflow.com/questions/5661596/do-i-need-a-content-type-for-http-get-requests). In short, using a content type with a GET isn't valid. – David Weldon Mar 02 '16 at 14:13
  • Ah that makes sense, I was getting the name of the header wrong, it was "Accept" that I was after. Thanks. – digitalWestie Mar 02 '16 at 14:24

0 Answers0