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

xhr-request

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xhr-request

tiny http client for Node and the browser

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
250K
decreased by-8.07%
Maintainers
1
Weekly downloads
 
Created

What is xhr-request?

The xhr-request npm package is a simple utility for making XMLHttpRequests in a Node.js environment. It provides a straightforward API for performing HTTP requests and handling responses, making it easier to interact with web services.

What are xhr-request's main functionalities?

Basic GET Request

This feature allows you to perform a basic GET request to a specified URL. The response data is handled in a callback function.

const xhrRequest = require('xhr-request');

xhrRequest('https://api.example.com/data', { method: 'GET' }, (err, data) => {
  if (err) throw err;
  console.log(data);
});

POST Request with Data

This feature allows you to perform a POST request with a JSON payload. The response data is handled in a callback function.

const xhrRequest = require('xhr-request');

const postData = { key: 'value' };
xhrRequest('https://api.example.com/data', { method: 'POST', json: true, body: postData }, (err, data) => {
  if (err) throw err;
  console.log(data);
});

Handling Response Headers

This feature allows you to access response headers along with the response data. The headers are available in the response object passed to the callback function.

const xhrRequest = require('xhr-request');

xhrRequest('https://api.example.com/data', { method: 'GET' }, (err, data, res) => {
  if (err) throw err;
  console.log('Response Headers:', res.headers);
  console.log('Response Data:', data);
});

Other packages similar to xhr-request

Keywords

FAQs

Package last updated on 03 Feb 2018

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