let root=document.getElementById('root'); let kontener=document.createElement('div'); kontener.setAttribute('class','flex flex-row flex-wrap items-center justify-center bg-sky-200'); fetch('https://jsonplaceholder.typicode.com/photos') .then(res=>res.json()) .then(kepek=>{ kepek.forEach(kep => { let kepKontener=document.createElement('div'); kepKontener.setAttribute('class','flex flex-col items-center justify-center bg-sky-400 m-2 p-2 rounded-xl w-96'); let title=document.createElement('p'); title.setAttribute('class','text-2xl text-center font-bold text-sky-600'); title.textContent=kep.title; let image=document.createElement('img'); image.setAttribute('class','rounded-xl'); image.src=kep.url; kepKontener.appendChild(image); kepKontener.appendChild(title); kontener.appendChild(kepKontener); }); }) .catch(err=>alert(err)); root.appendChild(kontener);