🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

get-it

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-it

Generic HTTP request library for node, browsers and workers

8.6.9
latest
Version published
Weekly downloads
584K
2.75%
Maintainers
88
Weekly downloads
 
Created

What is get-it?

get-it is a JavaScript HTTP client for making requests to APIs. It is designed to be modular and extensible, allowing developers to customize its behavior through plugins.

What are get-it's main functionalities?

Basic GET Request

This feature allows you to make a basic GET request to a specified URL. The response is handled using Promises.

const getIt = require('get-it');
const request = getIt();

request({ url: 'https://api.example.com/data' })
  .then(response => console.log(response))
  .catch(error => console.error(error));

Using Plugins

get-it supports middleware plugins to extend its functionality. In this example, the jsonResponse plugin is used to automatically parse JSON responses.

const getIt = require('get-it');
const jsonResponse = require('get-it/lib/middleware/jsonResponse');
const request = getIt([jsonResponse()]);

request({ url: 'https://api.example.com/data' })
  .then(response => console.log(response))
  .catch(error => console.error(error));

Custom Headers

You can add custom headers to your requests. This is useful for adding authentication tokens or other custom headers required by the API.

const getIt = require('get-it');
const request = getIt();

request({
  url: 'https://api.example.com/data',
  headers: { 'Authorization': 'Bearer token' }
})
  .then(response => console.log(response))
  .catch(error => console.error(error));

Other packages similar to get-it

FAQs

Package last updated on 19 May 2025

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