header-pagination
WIP - nothing to see here
Last updated 2 months ago by bret .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install header-pagination 
SYNC missed versions from official npm registry.

header-pagination

Actions Status

Parse rfc5988 style pagination Link headers from a fetch Response object.

npm install header-pagination

Usage

import { getPagination } from 'header-pagination'

window.fetch(req).then(async response => {
  const pagination = getPagination(response.headers)
  // {
  //    last,
  //    next,
  //    prev,
  //    first,
  //    current,
  //    total (if X-Total-Count is included)
  // }
  const json = await response.json()
  return {pagination, json}
})

API

getPagination(response)

Given a fetch Response, returns an object with the following properties:

{
  last,
  next,
  prev,
  first,
  current,
  total // if X-Total-Count is included
}

See also

License

MIT

Current Tags

  • 2.0.1                                ...           latest (2 months ago)

3 Versions

  • 2.0.1                                ...           2 months ago
  • 2.0.0                                ...           2 months ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 19
Dependencies (0)
None
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |