fetch-link-util
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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 = getLink(response.headers);
  } while (next);
}

API

Table of Contents

getHeaderLink

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 href for given rel or undefined

install

With npm do:

npm install fetch-link-util

license

BSD-2-Clause

Package Sidebar

Install

npm i fetch-link-util

Weekly Downloads

258

Version

1.1.1

License

BSD-2-Clause

Unpacked Size

7.25 kB

Total Files

5

Last publish

Collaborators

  • arlac77