gl-got

9.0.3 • Public • Published

gl-got Build Status

Convenience wrapper for got to interact with the GitLab API

Copied then adapted for GitLab from gh-got

Install

$ npm install --save gl-got

Usage

Instead of:

const got = require('got');
const token = 'foo';
 
got('https://gitlab.com/api/v3/users/979254', {
    json: true,
    headers: {
        'PRIVATE-TOKEN': `${token}`
    }
}).then(res => {
    console.log(res.body.username);
    //=> 'gl-got-tester'
});

You can do:

const glGot = require('gl-got');
 
glGot('users/979254', {token: 'foo'}).then(res => {
    console.log(res.body.username);
    //=> 'gl-got-tester'
});

Or:

const glGot = require('gl-got');
 
glGot('https://gitlab.com/api/v3/users/979254', {token: 'foo'}).then(res => {
    console.log(res.body.username);
    //=> 'gl-got-tester'
});

API

Same as got (including the stream API and aliases), but with some additional options below.

Errors are improved by using the custom GitLab error messages. Doesn't apply to the stream API.

token

Type: string

GitLab access token.

Can be set globally with the GITLAB_TOKEN environment variable.

baseUrl

Type: string
Default: https://gitlab.com/api/v3

Can be set globally with the GITLAB_ENDPOINT environment variable.

body

Type: Object

Can be specified as a plain object and will be serialized as JSON with the appropriate headers set.

License

MIT © Sindre Sorhus © Rhys Arkins

Dependencies (1)

Dev Dependencies (5)

Package Sidebar

Install

npm i gl-got

Weekly Downloads

1,088

Version

9.0.3

License

MIT

Unpacked Size

4.83 kB

Total Files

4

Last publish

Collaborators

  • hbetts
  • rarkins
  • singapore