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

bent

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bent

Functional HTTP client for Node.js w/ async/await.

  • 7.3.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
408K
increased by4.29%
Maintainers
1
Weekly downloads
 
Created

What is bent?

The 'bent' npm package is a minimalistic and efficient HTTP client for Node.js. It is designed to be simple and easy to use, providing a straightforward API for making HTTP requests. It supports promises and async/await syntax, making it a modern choice for handling HTTP requests in Node.js applications.

What are bent's main functionalities?

Making GET Requests

This feature allows you to make GET requests and automatically parse the response as JSON. The 'bent' function is configured with 'json' to handle JSON responses.

const bent = require('bent');
const getJSON = bent('json');
(async () => {
  const response = await getJSON('https://api.example.com/data');
  console.log(response);
})();

Making POST Requests

This feature allows you to make POST requests with a JSON payload. The 'bent' function is configured with 'POST' and 'json' to handle JSON responses and ensure a 200 status code.

const bent = require('bent');
const post = bent('POST', 'json', 200);
(async () => {
  const response = await post('https://api.example.com/data', { key: 'value' });
  console.log(response);
})();

Handling Different Response Types

This feature allows you to handle different response types, such as buffers for binary data. The 'bent' function is configured with 'buffer' to handle binary responses.

const bent = require('bent');
const getBuffer = bent('buffer');
(async () => {
  const response = await getBuffer('https://example.com/image.png');
  console.log(response);
})();

Custom Headers

This feature allows you to set custom headers for your HTTP requests. The 'bent' function is configured with 'GET', 'json', and a headers object to include an authorization token.

const bent = require('bent');
const getWithHeaders = bent('GET', 'json', { 'Authorization': 'Bearer token' });
(async () => {
  const response = await getWithHeaders('https://api.example.com/data');
  console.log(response);
})();

Other packages similar to bent

FAQs

Package last updated on 10 Oct 2020

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