0

I want to try and get data from an API but I am getting

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I cant change the content of API so I cant use JSONP

These are all I tried so far:

$.getJSON('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=keyhere&format=json&steamids=76561197970938759', function(data) {
  console.log(data);
});

$.get("http://www.api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=keyhere&format=json&steamids=76561197970938759", function(data) {
  console.log(data);
});

$.ajax({
  type: 'GET',
  url: 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=keyhere&format=json&steamids=76561197970938759',
  dataType: "json",
  success: function(data) {

    console.log(data)
  }


});
guradio
  • 15,524
  • 4
  • 36
  • 57

1 Answers1

1

As far as I know, if the server didn't enabled cross origin request in their headers, the browser will just not accept making an ajax call to it if you're on a different domain.

You could use your server to get the data and then send it to the client for example with CORS-Proxy or even use a website that does the proxying for you like CrossOrigin.me.

Maarethyu
  • 83
  • 1
  • 9
  • using `CrossOrigin.me.` would there be some security risk on my part or on the part of the one feeding the data? – guradio Dec 14 '16 at 02:38
  • @guradio `Crossorigin.me` would be technically able to see everything that go trough their servers, but `GetPlayerSummaries` doesn't really contain any private informations so the only thing that could be stolen is your api key, still not a big deal, if you have no other choice. – Maarethyu Dec 15 '16 at 09:50