Socket
Socket
Sign inDemoInstall

gl-got

Package Overview
Dependencies
24
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gl-got

Convenience wrapper for `got` to interact with the GitLab API


Version published
Weekly downloads
906
decreased by-14.04%
Maintainers
3
Install size
344 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 08 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc