我正在开发一个天气应用程序,并遵循来自Dev Ed的YouTube教程。我应该在控制台日志中获取一些信息,但是,我收到此错误,无法加载服务器响应状态为400的资源。我如何删除此语法错误,这似乎是其原因? 谢谢,Love2Code
<!DOCTYPE html>
<html>
<head>
<title>Local Weather</title>
<script>
window.addEventListener("load", () => {
//Asks user location
let long;
let lat;
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
long = position.coords.longitude;
lat = position.coords.latidute;
const proxy = "https://cors-anywhere.herokuapp.com/";
const api =`${proxy}https://api.darksky.net/forecast/217e0a6f0942213d0c3e6990a8b626f3/${lat},${long}`;
//Catches weather info from website
fetch(api)
.then(response => {
return response.json();
})
.then(data => {
console.log(data);
});
});
}
});
</script>
<style>
@media screen and (min-width:1px) and (max-width:1365px) {
...
}
@media screen and (min-width:1366px) {
...
}
*{
margin:0;
padding:0;
box-sizing:border-box;
}
body{
height:100vh;
display:flex;
justify-content:center;
flex-direction:column;
align-items:center;
background:linear-gradient(rgb(47,150,163), rgb(48,62,143));
font-family:sans-serif;
color:white;
}
.location, .temperature{
height:30vh;
width:50%;
display:flex;
justify-content:space-around;
align-items:center;
}
.temperature{
flex-direction:column;
}
.degree-section{
display:flex;
align-center:center;
cursor:pointer;
}
.degree-section span{
margin:10px;
font-size:30px;
}
.degree-section h2{
font-size:35px;
position:relative;
top:5px;
}
</style>
</head>
<body>
<div class="location">
<h1 class="location-timezone">Timezone</h1>
<p>Icon</p>
</div>
<div class="temperature">
<div class="degree-section">
<h2 class="temperature-degree">34</h2>
<span>F</span>
</div>
<div class="temperature-description">It's cold
</div>
</body>
</html>