src/static/js/admin-stats.js
// Populate posts on the stats page
Populate posts on the stats page
Populate posts on the stats page
async function populatePosts() {
  const postsURL = "/api/getPosts";
  let posts = null;
  try {
    posts = await fetchJSON(postsURL);
  } catch (err) {
    showError("Failed to update posts");
  }
  if (posts) {
    hideError();
    hideElement("posts-status");
    clearElement("site-posts");
    for (const post of posts) {
      const newItem = createPostRow(post);
      appendTo("site-posts", newItem);
    }
  }
}
async function populatePosts ( ) { const postsURL = "/api/getPosts" ; let posts = null ; try { posts = await fetchJSON ( postsURL ) ; } catch ( err ) { showError ( "Failed to update posts" ) ; } if ( posts ) { hideError ( ) ; hideElement ( "posts-status" ) ; clearElement ( "site-posts" ) ; for ( const post of posts ) { const newItem = createPostRow ( post ) ; appendTo ( "site-posts" , newItem ) ; } } }
Populate posts on the stats page
Populate posts on the stats page