function getInfo() {
fetch("https://swapi.co/api/people")
.then(response => response.json())
.then(function(data) {
console.log(data);
})
.catch(function(error) {
// If there is any error you will catch them here
console.log(error);
});
}
const newPerson = document.getElementById('newQuote')
newPerson.addEventListener('click', getInfo); // new quote on button click
window.onload = getInfo; // new quote on page load
我编写了这段代码并在控制台中收到以下消息:TypeError{}
慕尼黑8549860
相关分类