import './style.css' const app = document.querySelector('#app'); if (!app) { console.error('App container not found'); throw new Error('App container not found'); } app.innerHTML = '
'; try { const response = await fetch('http://localhost:8080/api/posts'); if (!response.ok) throw new Error(`HTTP ${response.status}`); const posts = await response.json(); app.innerHTML = ''; for (const post of posts) { const postHTML = `
avatar
@${post.authorHandle}
${post.text || '
'}
${new Date(post.createdAt).toLocaleString()}
`; app.innerHTML += postHTML; } } catch (err) { app.innerHTML = `
error loading posts: ${err}
`; }