我正在尝试从 JSON 文件中记录作者姓名和引用,但代码无法正常工作?
I am trying to log the author name and the quote from the JSON file, but the code is not working?
我正在尝试使用数据数组对象中的 quoteAuthor 和 quoteText 登录到控制台,但它不起作用有人可以帮助我吗,为什么这段代码不起作用?
const showJokes = () => {
return fetch("https://quote-garden.herokuapp.com/api/v3/quotes")
.then(response => response.json())
.then(data => {
data.data.forEach(message => {
let author = message.quoteAuthor;
let quote = message.quoteText;
return showAllJokes(`${author} - ${quote}`)
})
});
}
function showAllJokes(fullName) {
console.log(fullName);
}
json file
我只能在您提供的代码段中看到 functions
声明,也许您确实忘记调用 showJokes
函数?
const showJokes = () => {
return fetch("https://quote-garden.herokuapp.com/api/v3/quotes")
.then(response => response.json())
.then(data => {
data.data.forEach(message => {
let author = message.quoteAuthor;
let quote = message.quoteText;
return showAllJokes(`${author} - ${quote}`)
})
});
}
function showAllJokes(fullName) {
console.log(fullName);
}
showJokes() // <- Add this line
我正在尝试使用数据数组对象中的 quoteAuthor 和 quoteText 登录到控制台,但它不起作用有人可以帮助我吗,为什么这段代码不起作用?
const showJokes = () => {
return fetch("https://quote-garden.herokuapp.com/api/v3/quotes")
.then(response => response.json())
.then(data => {
data.data.forEach(message => {
let author = message.quoteAuthor;
let quote = message.quoteText;
return showAllJokes(`${author} - ${quote}`)
})
});
}
function showAllJokes(fullName) {
console.log(fullName);
}
json file
我只能在您提供的代码段中看到 functions
声明,也许您确实忘记调用 showJokes
函数?
const showJokes = () => {
return fetch("https://quote-garden.herokuapp.com/api/v3/quotes")
.then(response => response.json())
.then(data => {
data.data.forEach(message => {
let author = message.quoteAuthor;
let quote = message.quoteText;
return showAllJokes(`${author} - ${quote}`)
})
});
}
function showAllJokes(fullName) {
console.log(fullName);
}
showJokes() // <- Add this line