【发布时间】:2022-01-11 08:33:34
【问题描述】:
所有这一切都是我第一次尝试编写我的第一个 API 提取,我不断收到以下错误 Uncaught (in promise) ReferenceError response is not defined at getISS (index.html:19) 这些是似乎导致问题的 2 行:
const data = await response.json();
getISS();
不完全确定如何解决此问题。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
</head>
<title> API Test </title>
<body>
<h1>Where is the ISS? </h1>
<p>Latitude: <span id="lat"></span><br />
Longitude: <span id="lon"></span>
<script>
const iss_url = 'https://api.wheretheiss.at/v1/satellites/25544';
async function getISS() {
const respone = await fetch(iss_url);
**const data = await response.json();**
const { latitude, longitude } = data;
document.getElementById('lat').textContent = latitude;
document.getElementById('lon').textContent = longitude;
}
**getISS();**
</script>
</body>
</html>
【问题讨论】:
-
响应需要修复