gitlab-fetcher

0.2.3 • Public • Published

gitlab-fetcher

Simple helper to aggregate Gitlab API results across multiple pages

Usage

Fetching a paginated collection

import { fetchGitlab } from "gitlab-fetcher";

fetchGitlab("YourToken", "https://gitlab.url/projects/1/issues", { scope: "all", state: "opened" })
  .then(issues => {
    /* ... */
  })
  .catch(console.error);

issues will contain a Promise resolving to aggregated results from all result pages. An Error will be thrown in case of HTTP error (with message containing response.statusText).

Other requests (single entity, POST, etc.)

import { callGitlab } from "gitlab-fetcher";

callGitlab("YourToken", "https://gitlab.url/projects/1/issues", { /* ... */ }, "post")
  .then(response => response.json())
  .catch(console.error);

Server-side

This package can be easily used with Node.js and ESM:

/* eslint-env node */
global.fetch = require("node-fetch");
global.Headers = require("fetch-headers");

const { callGitlab, fetchGitlab } = require("gitlab-fetcher");

Simply run your script with node -r esm path/to/script.js.

Readme

Keywords

none

Package Sidebar

Install

npm i gitlab-fetcher

Weekly Downloads

4

Version

0.2.3

License

none

Unpacked Size

3.21 kB

Total Files

3

Last publish

Collaborators

  • neemzy