Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
request-promise-native
Advanced tools
The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.
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.
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);
});
Axios is a promise-based HTTP client for the browser and Node.js. It provides a simple and easy-to-use API for making HTTP requests and supports features like interceptors, automatic JSON transformation, and request cancellation. Compared to request-promise-native, Axios has a more modern API and is actively maintained.
Node-fetch is a lightweight module that brings the Fetch API to Node.js. It is a minimalistic library that provides a simple way to make HTTP requests using promises. Compared to request-promise-native, node-fetch has a smaller footprint and is more aligned with the Fetch API standard used in browsers.
Got is a human-friendly and powerful HTTP request library for Node.js. It supports promises, streams, retries, and many other advanced features. Compared to request-promise-native, Got offers a more feature-rich and flexible API, making it suitable for more complex use cases.
This package is similar to request-promise
but uses native ES6 promises.
Please refer to the request-promise
documentation. Everything applies to request-promise-native
except the following:
.finally(...)
method is not available.This module is installed via npm:
npm install --save request
npm install --save request-promise-native
request
is defined as a peer-dependency and thus has to be installed separately.
request-promise
to request-promise-native
request-promise
v4..finally(...)
anymore.To set up your development environment:
cd
to the main folder,npm install
,npm install gulp -g
if you haven't installed gulp globally yet, andgulp dev
. (Or run node ./node_modules/.bin/gulp dev
if you don't want to install gulp globally.)gulp dev
watches all source files and if you save some changes it will lint the code and execute all tests. The test coverage report can be viewed from ./coverage/lcov-report/index.html
.
If you want to debug a test you should use gulp test-without-coverage
to run all tests without obscuring the code by the test coverage instrumentation.
@request/promise-core
version for safer versioningrequest-promise
v4In case you never heard about the ISC license it is functionally equivalent to the MIT license.
See the LICENSE file for details.
FAQs
The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.
We found that request-promise-native demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.