无法访问itunes搜索API

时间:2015-12-21 15:48:35

标签: angularjs itunes-store

我试图使用带有angularjs的iTunes搜索API。这是我提出要求

var itunesURL = 'https://itunes.apple.com/search?'
var encoded = encodeURIComponent($scope.search);
var apiURL = itunesURL + 'term=' + encoded + '&country=US&media=music&limit=5';

$http({
        method: 'GET',
        url: apiURL
    }).then(function successCallback(response) {
        console.log(response.data);
    }, function errorCallback(response) {
        console.log('the request failed');
    });

范围内的搜索变量表示用户在搜索栏中输入的内容。但是我收到了这个错误...

XMLHttpRequest cannot load https://itunes.apple.com/search?term=What%20I%27ve%20Done&country=US&media=music&limit=5. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

0 个答案:

没有答案