Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fetching post list in TopPosts.js component #38

Closed
alexkisielewicz opened this issue Jun 27, 2023 · 1 comment
Closed

[BUG] Fetching post list in TopPosts.js component #38

alexkisielewicz opened this issue Jun 27, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@alexkisielewicz
Copy link
Owner

The fetchPostsByLikes function uses an Axios request to fetch a list of posts and order them based on the number of likes, from most liked to least liked. To verify its functionality, likes were added and removed on multiple posts. However, the result was that the list of fetched posts was incomplete, and the updates in likes were not visible in the TopPosts component.

Expected behavior
Function fetches a list of posts and orders them by likes count.

@alexkisielewicz alexkisielewicz added the bug Something isn't working label Jun 27, 2023
@alexkisielewicz alexkisielewicz self-assigned this Jun 27, 2023
@alexkisielewicz
Copy link
Owner Author

Upon investigating the backend, I discovered that it was overlooked that the API utilizes pagination to display posts. Consequently, only 10 posts were fetched, and some of the expected posts to which I had added likes were not included.

To fix the bug, I updated the function code by declaring an array to store all posts and a variable to hold the current page's posts. Now, posts are fetched from all existing pages and appended to the array of all posts. The sorting is then performed on the complete array of posts, ordering them from most liked to least liked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🐛 Bugs
Development

No branches or pull requests

1 participant