This package has been deprecated

Author message:

Not maintained, don't use this

dhttp

3.0.3 • Public • Published

dhttp

TRAVIS NPM

js-standard-style

Just another biased browserify-compatible HTTP/HTTPS/XHR wrapper. No compatability with IE.

Automatically parses application/json, text/(plain|html) and application/octet-stream.

Example

let dhttp = require('dhttp')
 
// ...
dhttp({
  method: 'GET',
  url: 'http://localhost:8000'
}, function (err, res) {
  // err is only provided if the connection failed in some way
  // OR if the content body parsing failed in some way
  if (err) return
  if (res.statusCode !== 200) return
  if (res.headers['content-type'] !== 'application/json') return
 
  // if `content-type` was not supported, expect body to be `null`
  console.log(res.body)
  // => { foo: 'bar' }, a parsed JSON object
 
  // ...
})

To bypass statusCode handling, you can use dhttp/200 which throws a descriptive error for any statusCode other than 200 using http-status-codes.

let dhttp = require('dhttp/200')
// ...

LICENSE MIT

Readme

Keywords

Package Sidebar

Install

npm i dhttp

Weekly Downloads

7,549

Version

3.0.3

License

MIT

Unpacked Size

9.6 kB

Total Files

8

Last publish

Collaborators

  • dcousens