-1

I try get banners information with angular js from thetvdb api, and not work. Here is the complete code:

var app = angular.module("tvdbApp", []);
app.controller('bannersCtl', function($scope, $http) {
    $http.jsonp(
        //'https://thetvdb.com/api/<myapikey>/series/274431/banners.xml' // gotham
        'https://thetvdb.com/api/<myapikey>/series/279121/banners.xml' // flash

    ).then(function(res) {
        console.log(res)
    }, function(res){
        console.error(res)
    })
}); 

Of course, the api key is valid.

When I try the url-s in the browser, works well, I got the XML.

What is the problem?

Thank you.

John Henry
  • 109
  • 2
  • 5
  • It's not duplicated, the other question is jquery and my problem is angular js + xml<>jsonp Only the error message matching. (of course) – John Henry Dec 21 '15 at 10:43

1 Answers1

1

The problem is that you are getting XML but you are trying to process it as JSONP.

Use $http.get if you aren't fetching JSONP.

(This assumes that thetvdb will provide CORS headers to give your JavaScript permission to access the data it is willing to send to your visitor's browsers, otherwise you would also need to use a proxy on the same origin)

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335