function loadData() { const element = document.querySelector("div#content"); getPosts().then(posts => { const template = getTemplate(posts); element.innerHTML = template; }); } async function getPosts() { const url = "https://jsonplaceholder.typicode.com/posts"; const response = await fetch(url); return await response.json(); } function getTemplate(posts) { const rows = posts.map(postToRowView).join(""); return `
${rows}
Title | Body |
---|
`; } function postToRowView(post) { return `${post.title}${post.body}`; } loadData();
google.jslm=3;