当我尝试从NASA的api加载图像时,它无法加载,但它不会显示任何错误,所以我必须做什么来解决它。
fetch("https://api.nasa.gov/planetary/apod?api_key=JMlSbTcc8JLfEfCVfPhppl0KVBUp4U6M4nhzXMTl")
.then((resp) => resp.json())
.then((json) => {
/*
document.querySelector("#title").innerHTML = json.title;
document.querySelector("#date").innerHTML = json.date;
document.querySelector("#expl").innerHTML = json.explanation;
document.querySelector("title").innerHTML = `Nasa Today | ${json.date}`
*/
document.querySelector("#spaceImg").innerHTML = `<img src="${json.hdurl}" style="height: 300px;">`
console.log(json);
})
<div id="spaceImg"></div>