fix: use link_header instead of add_link for pagination responses#81
fix: use link_header instead of add_link for pagination responses#81
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #81 +/- ##
=========================================
Coverage 83.33% 83.33%
Complexity 96 96
=========================================
Files 8 8
Lines 516 516
=========================================
Hits 430 430
Misses 86 86
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR uses
link_headerinstead ofadd_linkto add next/prev pagination links to keep the response as a pure array.When using
add_link,_linksis added to the response body, converting it from an array to a JSON object like{"0": {...}, "_links": {...}}.Note that this is a breaking fix from 0.1, though you would have only noticed if you set per_page to something low or had 50+ abilities.
See also #60 (comment).
Testing Instructions
/wp/v2/abilities?per_page=1and see that bothX-WP-TotalandX-WP-TotalPagesare set/wp/v2/abilities?per_page=1&page=2and see that the response is an array of items