A simple package with no dependencies for native requests using callback
Installations
npm install native-request
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.7.0
NPM Version
8.19.2
Score
87.1
Supply Chain
99.5
Quality
77.7
Maintenance
100
Vulnerability
100
License
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
ZaralDev
Download Statistics
Total Downloads
205,413,237
Last Day
17,119
Last Week
545,944
Last Month
2,321,522
Last Year
30,493,635
GitHub Statistics
4 Stars
42 Commits
2 Watching
5 Branches
2 Contributors
Bundle Size
2.40 kB
Minified
1.01 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.2
Package Id
native-request@1.1.2
Unpacked Size
29.80 kB
Size
5.48 kB
File Count
13
NPM Version
8.19.2
Node Version
20.7.0
Publised On
24 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
205,413,237
Last day
-8.7%
17,119
Compared to previous day
Last week
-5.2%
545,944
Compared to previous week
Last month
-10.4%
2,321,522
Compared to previous month
Last year
-37.7%
30,493,635
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
4
Native Request
v1.1 has been released
Native Request is a simple module that makes you create native node.js requests supports https.
- supports HTTPS
- 0 dependencies
- use callbacks
Table of Contents
Planned features
- 1.2.0: Proxy management
Installation
Install the dependencies and devDependencies and start the server.
1npm install native-request
Usage
JSON request (recommended)
- request.request(options, callback)
Easy
1let request = require('native-request'); 2 3request.request({ 4 url: "http://github.com/", 5 method: 'POST', 6 }, function(err, data, status, headers) { 7 console.log(status); //200 8 console.log(data); // page content 9 console.log(headers); // response headers 10}); 11
Full
1let request = require('native-request'); 2 3request.request({ 4 url: "http://github.com/", 5 method: 'POST', 6 Cookies: { john: "doe", human: true }, 7 headers: { 8 authorization: "Token121" 9 }, 10 requestOptions: { 11 followRedirect: false, 12 maxRedirect: 1, 13 trustRedirect: false 14 } 15 16 }, function(err, data, status, headers) { 17 console.log(status); //200 18 console.log(data); // page content 19 console.log(headers); // response headers 20}); 21
Parameters
Options | Required | Type | Parameters | Default |
---|---|---|---|---|
url | ✓ | String | Target url | |
method | ✓ | String | HTTP method to use. More info here | |
Headers | JSON Object | Pass headers to the request with a JSON format. | {"content-type": "application/json"} | |
Cookies | JSON Object | Pass cookies to the request with a JSON format | ||
requestOptions | See below |
RequestOptions
The parameters below are here for client configuration. None of these parameters will be sent. These parameters must be put in the object 'requestOptions'
Options | Required | Type | Parameters | Default |
---|---|---|---|---|
followRedirect | boolean | Decide if we should follow the redirects | true | |
maxRedirect | int | Decide the maximum number of redirects allowed | 3 | |
trustRedirect | boolean | If false, headers will not be sent when a redirect happen | true |
GET request
- request.get(path, headers, callback)
- request.get(path, callback)
1let request = require('native-request'); 2request.get('https://github.com', function(err, data, status, headers) { 3 if (err) { 4 throw err; 5 } 6 console.log(status); //200 7 console.log(data); // page content 8 console.log(headers); // response headers 9});
To add custom headers just do like this:
1let request = require('native-request'); 2 3let headers = { 4 "content-type": "plain/text" 5} 6request.get('https://github.com', headers, function(err, data, status, headers) { 7 if (err) { 8 throw err; 9 } 10 console.log(status); //200 11 console.log(data); // page content 12 console.log(headers); // response headers 13});
POST request
-
request.post(path, callback)
-
request.post(path, data, callback)
-
request.post(path, data, headers, callback)
To send an empty post:
1let request = require('native-request'); 2request.post('https://github.com', function(err, data, status, headers) { 3 if (err) { 4 throw err; 5 } 6 console.log(status); //200 7 console.log(data); // page content 8 console.log(headers); // response headers 9});
With headers and data:
1let request = require('native-request'); 2 3let data = { 4 "example": true, 5} 6let headers = { 7 "content-type": "plain/text" 8} 9request.post('https://github.com', data, headers, function(err, data, status, headers) { 10 if (err) { 11 throw err; 12 } 13 console.log(status); //200 14 console.log(data); // page content 15 console.log(headers); // response headers 16});
License
MIT. Copyright (c) Samuel Marchese.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 10 are checked with a SAST tool
Reason
12 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
Score
1.3
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to native-request
request-promise-native
The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.
cacheable-request
Wrap native HTTP requests with RFC compliant cache support
@types/request-promise-native
TypeScript definitions for request-promise-native
@algolia/requester-node-http
Promise-based request library for node using the native http module.