Advertisement
Guest User

Untitled

a guest
May 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const renderFetchData = () => {
  2.     selectors.postsContainer.innerHTML = `
  3.     <tr>
  4.         <th>Title</th>
  5.         <th>Upvotes</th>
  6.         <th>Score</th>
  7.         <th>Comments</th>
  8.         <th>Created</th>
  9.     </tr>
  10. `
  11.     getResults().then(posts => {
  12.         let markup = ``
  13.         posts.posts.forEach(post => {
  14.             markup += `
  15.                     <tr>
  16.                         <td>${post.title}</td>
  17.                         <td>${post.upvotes}</td>
  18.                         <td>${post.score}</td>
  19.                         <td>${post.num_comments}</td>
  20.                         <td>${post.created}</td>
  21.                     </tr>
  22.             `
  23.         })
  24.         selectors.postsContainer.insertAdjacentHTML('beforeend', markup)
  25.     })
  26. }
  27.  
  28. const renderFromYesterday = () => {
  29.     let markup = ``
  30.     selectors.postsContainer.innerHTML = `
  31.         <tr>
  32.             <th>Title</th>
  33.             <th>Upvotes</th>
  34.             <th>Score</th>
  35.             <th>Comments</th>
  36.             <th>Created</th>
  37.         </tr>
  38.     `
  39.     getResults().then(posts => {
  40.         const yesterday = getPostsFromYesterday(posts.posts)
  41.        
  42.         yesterday.forEach(post => {
  43.             markup += `
  44.                     <tr>
  45.                         <td>${post.title}</td>
  46.                         <td>${post.upvotes}</td>
  47.                         <td>${post.score}</td>
  48.                         <td>${post.num_comments}</td>
  49.                         <td>${post.created}</td>
  50.                     </tr>
  51.             `
  52.         })
  53.         selectors.postsContainer.insertAdjacentHTML('beforeend', markup)
  54.     })
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement