Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gitbeaker/requester-utils

Package Overview
Dependencies
Maintainers
1
Versions
266
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gitbeaker/requester-utils

Utility functions for requester implementatons used in @gitbeaker

  • 41.2.0
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
763K
decreased by-14.23%
Maintainers
1
Weekly downloads
 
Created

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

Keywords

FAQs

Package last updated on 10 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc