【发布时间】:2016-08-01 19:00:53
【问题描述】:
我正在尝试向 Spotify Api 发出简单的获取授权请求。如果我发出一个 GET HTTPRequest,那么我会收到一个跨域错误。因此,我使用回调发出 JSONP 请求,但这会导致 MIME 类型错误,如上所示,我发现其解决方法是再次发出 HTTPRequest JSON 请求以匹配 MIME 类型。我在这里陷入了僵局!请帮忙!谢谢
这是我的 js 代码块:
(function(){
var script = document.createElement('script');
script.src = 'https://accounts.spotify.com/authorize?client_id=CLIENT_ID&response_type=code&redirect_uri=https://samcasm.github.io/moodsetNow/moodset.html&scope=user-read-private%20user-read-email&state=34fFs29kd09?callback=mySpotify';
document.getElementsByTagName('body')[0].appendChild(script);
})();
function mySpotify(){
console.log(response);
}
【问题讨论】:
-
@J F 你去@JF
-
@J F 没错,我正在尝试加载授权 html 文件作为来自 Api 的响应。该请求在 POSTMAN 上运行良好
标签: javascript ajax api spotify