Hello, I am facing an issue while trying to loop through an array or object. Can someone help me out? Are arrays and objects different when it comes to using foreach?
function fetchData() {
fetch("https://covid-193.p.rapidapi.com/statistics", {
"method": "GET",
"headers": {
"x-rapidapi-host": "covid-193.p.rapidapi.com",
"x-rapidapi-key": "c44a47562cmsh6ff0d107514bccfp146d00jsn876b11317ac5"
}
})
.then(res => res.json())
.then(res => res.response)
.then(data => {
data.foreach(item => console.log(item))
})
}
fetchData()
The error message in the console reads:
app.js:12 Uncaught (in promise) TypeError: cc.foreach is not a function
Thank you.