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

postman-request

Package Overview
Dependencies
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postman-request

Simplified HTTP request client.

  • 2.88.1-postman.40
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
925K
decreased by-13.1%
Maintainers
4
Weekly downloads
 
Created

What is postman-request?

The postman-request npm package is a simplified HTTP client that allows you to make HTTP requests in a straightforward manner. It is designed to be easy to use and integrates well with the Postman API testing tool.

What are postman-request's main functionalities?

Making a GET request

This feature allows you to make a simple GET request to a specified URL. The callback function handles the response, error, and body of the request.

const request = require('postman-request');

request('https://jsonplaceholder.typicode.com/posts/1', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body);
  }
});

Making a POST request

This feature allows you to make a POST request with a JSON body. The options object specifies the URL, method, and body of the request.

const request = require('postman-request');

const options = {
  url: 'https://jsonplaceholder.typicode.com/posts',
  method: 'POST',
  json: true,
  body: {
    title: 'foo',
    body: 'bar',
    userId: 1
  }
};

request(options, function (error, response, body) {
  if (!error && response.statusCode == 201) {
    console.log(body);
  }
});

Setting custom headers

This feature allows you to set custom headers for your HTTP request. The options object includes a headers property where you can specify the headers.

const request = require('postman-request');

const options = {
  url: 'https://jsonplaceholder.typicode.com/posts/1',
  headers: {
    'User-Agent': 'request'
  }
};

request(options, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body);
  }
});

Other packages similar to postman-request

Keywords

FAQs

Package last updated on 04 Sep 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