0

Please why no output

Please what could be wrong with my code..I get a blank page when I try to output. https://code.sololearn.com/W3Ytp1zYpf4F/?ref=app

12th Oct 2022, 5:15 PM
steve Purpose
steve  Purpose - avatar
5 Respostas
+ 3
function getData(){ fetch("https://www.boredapi.com/api/activity") .then((respobj)=>respobj.json()) .then((data)=>{ var show=`<h1>Activities</h1>` show+=` <div> <h2>${data.activity}</h2> <p>${data.type}</p> </div> ` stuff.innerHTML=show }) } getData()
12th Oct 2022, 7:27 PM
Solo
Solo - avatar
+ 2
It all depends on how the database is formed.
13th Oct 2022, 12:16 AM
Solo
Solo - avatar
+ 1
Because "data" is not an iterable object, it does not have a "forEach" function.
12th Oct 2022, 8:16 PM
Solo
Solo - avatar
0
Ok Solo ..But why did you take out the forEach
12th Oct 2022, 7:54 PM
steve Purpose
steve  Purpose - avatar
0
I get your point @solo ..it appears a post at a time.But checkout this other code.it fetches multiple posts at once https://code.sololearn.com/WCFQ4RkwZScC/?ref=app
12th Oct 2022, 8:30 PM
steve Purpose
steve  Purpose - avatar