amcharts / dataloader

Apache License 2.0
25 stars 25 forks source link

Accept headers not set #11

Open antiquechrono opened 8 years ago

antiquechrono commented 8 years ago

I just ran into an issue where Firefox wouldn't load any json graphs whereas Chrome would. It seems that Firefox sets a very specific accept header

text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

that sets other accepted formats whereas chrome sets it as / . The particular service I'm pulling data from can return xml or json depending on the accept headers and was choosing to return xml since the default header includes it.

It seems to me that a sensible default would be to set application/json or text/csv based on what is specified in the dataLoader section with the option to override the defaults through the use of the headers array which is what I used to fix this problem.

Also, the fact that you can specify the accept headers is not specified on this page http://www.amcharts.com/tutorials/using-data-loader-plugin/

martynasma commented 8 years ago

Hi there,

We do not set any specific headers for the requests. However, you can use headers array to override specific headers for all Data Loader requests:

"dataLoader": {
  "url": "data/serial.json",
  "format": "json",
  "headers": [{
    "key": "Accept",
    "value": "application/javascript, application/json"
  }]
}

I hope this helps.