我没有通过请求此 API 在控制台中获取 JSON 数据:https://amlocatapi.us-south.cf.appdomain.cloud/location 使用此标头
{
method:'GET',
headers:{
'Authorization':'1q2w3e4r5t6yu7i8',
'Content-Type':'application/json'
}
}
<html>
<head></head>
<body>
Hello
</body>
<script>
fetch('https://amlocatapi.us-south.cf.appdomain.cloud/location',
{
method:'GET',
headers:{
'Authorization':'1q2w3e4r5t6yu7i8',
'Content-Type':'application/json'
}
}
).then(response => response.json())
.then(json => console.log(json))
.catch(err => console.log(err));
</script>
</html>
尝试删除
'Content-Type': 'application/json'
标题。由于您正在发出 GET 请求,因此不需要它。控制台的响应是什么?您检查了网络请求吗?