Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.travis.yml feat: Update to Got 9, rename `endpoint` option and require Node.js 8 ( Aug 23, 2018
index.js fix: recreate (#39) Jan 8, 2019
license Bump to got@7 Jun 24, 2017
package.json
readme.md
test.js fix: make use of private tokens possible again Oct 17, 2018
yarn.lock fix: make use of private tokens possible again Oct 17, 2018

readme.md

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

You can’t perform that action at this time.