Fetch Data, Loops through Array and adds to the DOM

PHOTO EMBED

Tue Nov 09 2021 12:24:42 GMT+0000 (Coordinated Universal Time)

Saved by @Sensei_p

fetch("https://apis.scrimba.com/jsonplaceholder/posts")
    .then(res => res.json())
    .then(data => {
        const postsArr = data.slice(0, 5)
        let html = ""
        for (let post of postsArr) {
            html += `
                <h3>${post.title}</h3>
                <p>${post.body}</p>
                <hr />
            `
        }
        document.getElementById("blog-list").innerHTML = html
    })
content_copyCOPY

Scrimba