🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

request-promise-native

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-promise-native

The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.

1.0.9
latest
Source
npm
Version published
Weekly downloads
9.4M
28.45%
Maintainers
2
Weekly downloads
 
Created

What is request-promise-native?

The request-promise-native npm package is a simplified HTTP request client for Node.js, which supports Promises. It is built on top of the popular 'request' library and provides a more modern and convenient way to handle HTTP requests using native ES6 promises.

What are request-promise-native's main functionalities?

Making a GET request

This feature allows you to make a simple GET request to a specified URL and handle the response using promises.

const rp = require('request-promise-native');

rp('https://jsonplaceholder.typicode.com/posts/1')
  .then(function (response) {
    console.log(JSON.parse(response));
  })
  .catch(function (err) {
    console.error(err);
  });

Making a POST request

This feature allows you to make a POST request with a JSON body to a specified URL and handle the response using promises.

const rp = require('request-promise-native');

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

rp(options)
  .then(function (response) {
    console.log(response);
  })
  .catch(function (err) {
    console.error(err);
  });

Handling request options

This feature allows you to customize your HTTP request by specifying various options such as headers, query parameters, and response format.

const rp = require('request-promise-native');

const options = {
  uri: 'https://jsonplaceholder.typicode.com/posts/1',
  headers: {
    'User-Agent': 'Request-Promise'
  },
  json: true
};

rp(options)
  .then(function (response) {
    console.log(response);
  })
  .catch(function (err) {
    console.error(err);
  });

Other packages similar to request-promise-native

Keywords

xhr

FAQs

Package last updated on 22 Jul 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