-1

trying to access an api with angularjs:

eg.

 footballdataAPI.getTeams = function() {
        $http.defaults.headers.common['Auth-Token'] = '613a6b6937394ae8a94d69f358f76902';
        return $http.get('http://www.football-data.org/alpha/soccerseasons/398/leagueTable?callback=JSON_CALLBACK');
    };

But I get the console error:

XMLHttpRequest cannot load http://www.football-data.org/alpha/soccerseasons/398/leagueTable?callback=JSON_CALLBACK. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://alexanderlloyd.info' is therefore not allowed access.

Do they need to allow requests from my domain on their side? Or is there something I can add to make this work ad they have already given me an authorisation token as shown in the code.

Thanks!

user1937021
  • 10,151
  • 22
  • 81
  • 143
  • possible duplicate of [No 'Access-Control-Allow-Origin' header is present on the requested resource- AngularJS](http://stackoverflow.com/questions/24134117/no-access-control-allow-origin-header-is-present-on-the-requested-resource-an) – Atais Aug 09 '15 at 10:16

1 Answers1

2

The server must send the Access-Controll-Allow-Origin header, telling the browser that requests from your application's host are allowed - otherwise the browser refuses to make such request (as a built-in security measure).

If interested, you can read a much more detailed explanation here.

plamut
  • 3,085
  • 10
  • 29
  • 40