You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@algolia/requester-node-http

Package Overview
Dependencies
Maintainers
3
Versions
194
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.


Version published
Weekly downloads
1.5M
decreased by-3.65%
Maintainers
3
Created
Weekly downloads
 

Package description

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

Changelog

Source

v4.23.3

  • fix(types): add serverTimeMS to search response (#1518) (a1d1707), closes #1518

FAQs

Package last updated on 10 Apr 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc