Angularjs Can';t访问itunes搜索API

Angularjs Can';t访问itunes搜索API,angularjs,itunes-store,Angularjs,Itunes Store,我正在尝试将iTunes搜索API与angularjs结合使用。这是我的请求 var itunesURL = 'https://itunes.apple.com/search?' var encoded = encodeURIComponent($scope.search); var apiURL = itunesURL + 'term=' + encoded + '&country=US&media=music&limit=5'; $http({ me

我正在尝试将iTunes搜索API与angularjs结合使用。这是我的请求

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.

问题出在你的错误陈述中。您没有访问该资源的权限
Access Control Allow Origin
header是一个服务器端头(即,它必须由Apple,Inc.设置)。我如何获得对资源的访问权限?可能会将
etc/hosts
文件中的
localhost
别名复制到其他文件,如下所示:
127.0.0.1 localhost something other.com
此处详细介绍,在公园里。您需要创建动态脚本标记,并提供一个
&callback={function name}
参数,有效地使调用成为
jsonp
。有关
jsonp
的更多信息以及如何使用它跨不同域访问数据,请参阅。