Socket
Socket
Sign inDemoInstall

@gitbeaker/requester-utils

Package Overview
Dependencies
12
Maintainers
1
Versions
246
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gitbeaker/requester-utils

Utility functions for requester implementatons used in @gitbeaker


Version published
Maintainers
1
Install size
467 kB
Created

Package description

What is @gitbeaker/requester-utils?

@gitbeaker/requester-utils is a utility package designed to facilitate HTTP requests, particularly in the context of interacting with GitLab's API. It provides a set of tools to simplify the process of making authenticated requests, handling responses, and managing configurations.

What are @gitbeaker/requester-utils's main functionalities?

Authenticated Requests

This feature allows you to create a requester function that automatically includes authentication headers in your HTTP requests. The code sample demonstrates how to create a requester and make a GET request to fetch projects.

const { createRequesterFn } = require('@gitbeaker/requester-utils');

const requester = createRequesterFn({
  host: 'https://gitlab.example.com',
  token: 'your_access_token',
});

requester.get('/projects')
  .then(response => console.log(response))
  .catch(error => console.error(error));

Custom Request Configurations

This feature allows you to customize various request configurations such as timeout settings. The code sample shows how to set a custom request timeout.

const { createRequesterFn } = require('@gitbeaker/requester-utils');

const requester = createRequesterFn({
  host: 'https://gitlab.example.com',
  token: 'your_access_token',
  requestTimeout: 5000,
});

requester.get('/projects')
  .then(response => console.log(response))
  .catch(error => console.error(error));

Handling Responses

This feature provides a way to handle responses and errors effectively. The code sample demonstrates how to check the response status and handle errors.

const { createRequesterFn } = require('@gitbeaker/requester-utils');

const requester = createRequesterFn({
  host: 'https://gitlab.example.com',
  token: 'your_access_token',
});

requester.get('/projects')
  .then(response => {
    if (response.status === 200) {
      console.log('Projects:', response.data);
    } else {
      console.error('Error:', response.statusText);
    }
  })
  .catch(error => console.error('Request failed:', error));

Other packages similar to @gitbeaker/requester-utils

Changelog

Source

28.4.1 (Tue May 04 2021)


Readme

Source

gitbeaker

Gitlab Pipeline Status Code Climate maintainability CodeCov test coverage Dependency Status Dev Dependency Status Dependabot Badge Auto Prettier Licence: MIT Install Size: Requester Utils

A Utility library for creating custom requesters for @gitbeaker to use

Read More

Keywords

FAQs

Last updated on 04 May 2021

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