Get all posts with pagination
pierresaid opened this issue · comments
pierresaid commented
route
/posts?page=1&posts_per_page=10&userid=42
This route should return posts_per_page
number of posts with an offset of page * posts_per_page
params | description |
---|---|
page | the pagination number |
posts_per_page | number of posts per pages |
userid | id of the user to use for user_vote in response |
returns
[
{
"id": "1",
"title": "Wich one is nicer ?",
"url_one": "https://cat.png",
"url_two": "https://dog.png",
"author_id" : 1,
"author_name" : "Clem",
"votes_one": 42,
"votes_two": 445,
"user_vote": -1 || 0 || 1
}
]
field | description |
---|---|
votes_one | number of votes for the first picture (url_one) |
votes_two | number of votes for the second picture (url_two) |
user_vote | the vote of the user referenced in user_id in route parameters -1 if no vote 0 if first 1 if second |
pierresaid commented
Add author_name in the response
PÉAU Clément commented
Votes are returned from the route. Still missing the author_name which needs to be fetched from the user_db.