Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fetch-link-util

arlac773.4k0BSD1.1.3TypeScript support: included

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

RFC-8288, fetch, link, paging, rel

readme

npm License Typed with TypeScript bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

fetch-link-util

helper to extract fetch link header values (https://datatracker.ietf.org/doc/html/rfc8288)

Example

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);
}

API

Table of Contents

Decodes link header and delivers one href entry.

Parameters

  • headers Headers as given by fetch response
  • rel string of link to retrieve (optional, default "next")

Returns (string | undefined) href for given rel

install

With npm do:

npm install fetch-link-util

license

BSD-2-Clause