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

@algolia/requester-node-http

Package Overview
Dependencies
Maintainers
3
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/requester-node-http

Promise-based request library for node using the native http module.

  • 5.17.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
decreased by-20.08%
Maintainers
3
Weekly downloads
 
Created

What is @algolia/requester-node-http?

@algolia/requester-node-http is a Node.js HTTP requester designed to be used with Algolia's API clients. It provides a simple and efficient way to make HTTP requests, particularly suited for interacting with Algolia's services.

What are @algolia/requester-node-http's main functionalities?

Basic HTTP Request

This feature allows you to make a basic HTTP GET request using the @algolia/requester-node-http package. The code sample demonstrates how to create a requester and send a GET request to a specified URL.

const { createNodeHttpRequester } = require('@algolia/requester-node-http');

const requester = createNodeHttpRequester();

const request = {
  method: 'GET',
  url: 'https://example.com',
  headers: {},
  data: null,
  responseType: 'json'
};

requester.send(request).then(response => {
  console.log(response);
}).catch(error => {
  console.error(error);
});

POST Request with Data

This feature allows you to make a POST request with a JSON payload. The code sample demonstrates how to create a requester and send a POST request with data to a specified URL.

const { createNodeHttpRequester } = require('@algolia/requester-node-http');

const requester = createNodeHttpRequester();

const request = {
  method: 'POST',
  url: 'https://example.com/api',
  headers: { 'Content-Type': 'application/json' },
  data: JSON.stringify({ key: 'value' }),
  responseType: 'json'
};

requester.send(request).then(response => {
  console.log(response);
}).catch(error => {
  console.error(error);
});

Handling Response and Errors

This feature demonstrates how to handle responses and errors from HTTP requests. The code sample shows how to log the response or error to the console.

const { createNodeHttpRequester } = require('@algolia/requester-node-http');

const requester = createNodeHttpRequester();

const request = {
  method: 'GET',
  url: 'https://example.com',
  headers: {},
  data: null,
  responseType: 'json'
};

requester.send(request).then(response => {
  console.log('Response:', response);
}).catch(error => {
  console.error('Error:', error);
});

Other packages similar to @algolia/requester-node-http

FAQs

Package last updated on 11 Dec 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