min-request
Advanced tools
| language: node_js |
+10
-2
| { | ||
| "name": "min-request", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "main": "request.js", | ||
@@ -14,3 +14,11 @@ "scripts": { | ||
| "http" | ||
| ] | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/chunpu/min-request.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/chunpu/min-request/issues" | ||
| }, | ||
| "homepage": "https://github.com/chunpu/min-request" | ||
| } |
+43
-0
| min-request | ||
| === | ||
| [![build status][travis-image]][travis-url] | ||
| For people who cannot understand [request](https://github.com/request/request) like me to use request | ||
| Support string, json, stream, buffer | ||
| === | ||
| Install | ||
@@ -14,4 +22,39 @@ --- | ||
| request(url, [options], callback) | ||
| callback param is like `request@request`: err, res, body | ||
| Simplest | ||
| ```js | ||
| var request = require('min-request') | ||
| request('localhost:8080/test', function(err, res, body) { | ||
| console.log(err, body) | ||
| }) | ||
| ``` | ||
| Request with data like json, stream | ||
| ```js | ||
| var request = require('min-request') | ||
| // json | ||
| request('localhost:8080/upload', { | ||
| method: 'POST', | ||
| body: {foo: 'bar'} | ||
| },function(err, res, body) { | ||
| // ... | ||
| }) | ||
| // stream | ||
| var fs = require('fs') | ||
| request('localhost:8080/upload', { | ||
| method: 'POST', | ||
| body: fs.createReadStream('./foo.bar') | ||
| }, function(err, res, body) { | ||
| // ... | ||
| }) | ||
| ``` | ||
| [travis-image]: https://img.shields.io/travis/chunpu/min-request.svg?style=flat | ||
| [travis-url]: https://travis-ci.org/chunpu/min-request |
+6
-2
@@ -22,3 +22,2 @@ var http = require('http') | ||
| hostname: parsed.hostname | ||
| , method: opt.method || 'GET' | ||
| , port: parsed.port | ||
@@ -28,6 +27,8 @@ , path: parsed.path | ||
| } | ||
| var body = opt.body | ||
| var method = 'GET' | ||
| var body = opt.body || opt.data | ||
| var type, len | ||
| if (null != body) { | ||
| // string, buffer, stream, object | ||
| method = 'POST' | ||
| if (Buffer.isBuffer(body)) { | ||
@@ -52,2 +53,3 @@ type = 'bin' | ||
| options.headers = headers | ||
| options.method = opt.method || method | ||
| var req = http.request(options, function(res) { | ||
@@ -62,2 +64,3 @@ var body = '' | ||
| }).on('error', cb) | ||
| if (body) { | ||
@@ -70,3 +73,4 @@ if (canPipe(body)) { | ||
| } | ||
| req.end() | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
4015
43.6%6
20%89
2.3%1
-50%0
-100%60
252.94%1
-50%