V
Size: a a a
V
AK
V
AK
V
V
AK
F
F
AK
F
F
V
F
AK
F
M
V
``
window.onload = () => {
addPost();
getPosts();
}
async function getPosts() {
const res = await fetch(window.location.href + 'api/posts');
const posts = await res.json();
posts.forEach(post => {
document.querySelector('.post-list').innerHTML += `
<div class="card">
<h5>${post.title}</h5>
<p>${post.body}</p>
<a href="">Read More</a>
</div>
`
})
}
function addPost() {
let title = document.getElementById("title")
let body = document.getElementById('body').value
document.getElementById('addPost').addEventListener('click', () => {
console.log(title.value)
console.log(body)
})
}
AK