helper to extract fetch link header values (paging/RFC-8288)
npm install fetch-link-util










helper to extract fetch link header values (https://datatracker.ietf.org/doc/html/rfc8288)
``js
import { getHeaderLink } from "fetch-link-util";
async listAllBranches() {
let next = "https://api.github.com/repos/arlac77/fetch-link-util/branches";
do {
const response = await fetch(next);
const json = await response.json();
console.log(json.map(branch => branch.name));
next = getHeaderLink(response.headers);
} while (next);
}
`
* See:
Decodes link header and delivers one href entry.
* headers Headers as given by fetch responserel
* string of link to retrieve (optional, default "next")
Returns (string | undefined) href for given rel
With npm do:
`shell``
npm install fetch-link-util
BSD-2-Clause