【发布时间】:2016-07-12 22:46:32
【问题描述】:
我正在尝试使用 iTunes 搜索 API 和 fetch api。
当我尝试以下操作时,我会在控制台中得到响应。
fetch('https://api.github.com/users/bootstrap').then(function(response) {
return response.json();
}).then(function(j) {
console.log(j);
});
但是当我尝试时
fetch('https://itunes.apple.com/search?term=jack+johnson',{mode: 'no-cors'}).then(function(response) {
return response.json();
}).then(function(a) {
console.log(a);
});
我收到一个错误Uncaught (in promise) SyntaxError: Unexpected end of input(…)
这样可以抓取iTunes API数据吗?
谢谢, 戴夫
【问题讨论】:
标签: javascript fetch-api