Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const renderFetchData = () => {
- selectors.postsContainer.innerHTML = `
- <tr>
- <th>Title</th>
- <th>Upvotes</th>
- <th>Score</th>
- <th>Comments</th>
- <th>Created</th>
- </tr>
- `
- getResults().then(posts => {
- let markup = ``
- posts.posts.forEach(post => {
- markup += `
- <tr>
- <td>${post.title}</td>
- <td>${post.upvotes}</td>
- <td>${post.score}</td>
- <td>${post.num_comments}</td>
- <td>${post.created}</td>
- </tr>
- `
- })
- selectors.postsContainer.insertAdjacentHTML('beforeend', markup)
- })
- }
- const renderFromYesterday = () => {
- let markup = ``
- selectors.postsContainer.innerHTML = `
- <tr>
- <th>Title</th>
- <th>Upvotes</th>
- <th>Score</th>
- <th>Comments</th>
- <th>Created</th>
- </tr>
- `
- getResults().then(posts => {
- const yesterday = getPostsFromYesterday(posts.posts)
- yesterday.forEach(post => {
- markup += `
- <tr>
- <td>${post.title}</td>
- <td>${post.upvotes}</td>
- <td>${post.score}</td>
- <td>${post.num_comments}</td>
- <td>${post.created}</td>
- </tr>
- `
- })
- selectors.postsContainer.insertAdjacentHTML('beforeend', markup)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement