Closed navjot50 closed 4 years ago
Instead of breaking on an exception you can check if you get as many posts as you're expecting. By default the API will return a max. of 10 posts, but you can set that to a maximum of 100 which should already reduce the amount of requests dramatically.
Returning the X-WP-TotalPages might be something to look at, would need to think about how to best provide this without cluttering the response.
Yes, I ended up doing the same as you suggested.
I want to get all the posts that are created by a given author. The function GetPostsByAuthor in the Posts class just gives the the first 10 posts by a given author. Also the method GetAll which the Posts class inherits from CRUDOperation class gets all the posts regardless of any filtering on the basis of author id.
Another thing is that we cannot get the response headers as the requests are executed internally by the HttpHelper classes, so there is no way to determine how many X-WP-TotalPages are there.
One ugly workaround that i found out is:
I don't like the fact that we have a while loop on true and that we have to expect an exception to break the loop. Is there a better way to do this?