【发布时间】:2018-06-11 06:39:51
【问题描述】:
我正在从 gltich API 获取 json 数据。
当我转到该链接时,网址会重定向到另一个域
https://wind-bow.glitch.me/twitch-api/users/freecodecamp
(域名从
gomix.me更改为glitch.me)
对两个 HTTPS 请求使用 postman,我得到相同的 JSON 数据。但是,当使用 jQuery .getJSON 方法时,两者都不会产生相同的结果
$(document).ready(function() {
$.getJSON("https://wind-bow.gomix.me/twitch-api/users/freecodecamp", function(data1) {
console.log("Gomix.me URL", data1); // nothing outputted
});
$.getJSON("https://wind-bow.glitch.me/twitch-api/users/freecodecamp", function(data2) {
console.log("Glitch.me URL", data2); // expected data outputted
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
是否可以通过将重定向gomix.me 的 URL 获取 JSON 数据,还是我只能使用最终端点 glitch.me?
【问题讨论】:
标签: javascript jquery json .htaccess redirect