Simple request, For people who cannot understand request like me to use http request
npm install min-request
Support body types
- string
- json
- stream
- buffer
request(url, [options], callback)
callback param is just like request@request
: err, res, body
Simplest
var request = require('min-request')
request('localhost:8080/test', function(err, res, body) {
console.log(err, body)
})
Request with data like json, stream
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) {
// ...
})
ISC