tiny-request

2.0.0 • Public • Published

NPM version Build status Test coverage License Dependency status

tiny-request

  • a tiny http.request wrapper, useful for some http sdk modules.

usage

  • options: same to http.request options, add timeout, source, body, dest support

    • timeout: type {Number}
    • source: type {String} - filepath|{Stream}|{Buffer}, will pipe to req
    • body: http body, type {Buffer}|{String}|{Object}
    • dest: filepath pipe from the res, {String}
    • rawBody: options pass to raw-body
  • res: type object

    • status
    • headers
    • body
let request = require('tiny-request')
 
let result = await request(options)
request({
  host: '',
  port: '',
  method: 'PUT',
  source: __filename,
  dest: __filename + '.temp'
}).then(function(res) {
  // ...
}).catch(function(err) {
  // ...
})

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i tiny-request

Weekly Downloads

0

Version

2.0.0

License

MIT

Last publish

Collaborators

  • coderhaoxin