Some API endpoints will return paginated results. When results are paginated, the server will return 3 headers related to pagination:
  • X-Per-Page: number of results return per page
  • X-Page: Id of the current page
  • X-Total: total number of results available
  • Link: URLs helpers for navigation
The Link header may contain up to 4 different URLs:
<>; rel="first",
<>; rel="last",
<>; rel="next",
<>; rel="prev"
  • rel="first": first page of the results
  • rel="last": last page of the results
  • rel="next": next page of results
  • rel="prev": previous page of results
To iterate on results, you simply need to parse the Link header to find the rel="next" link. If the link doesn't exist, then it means that there are no more pages to display.


Using JS
import parse from 'parse-link-header';
const getNextPage = (response) => {
if (response && response.headers && {
const links =;
const parsed = parse(links);
if (parsed && {
return null;
Last modified 2mo ago