3.0.3 • Published 6 years ago

dhttp v3.0.3

Weekly downloads
435
License
MIT
Repository
github
Last release
6 years ago

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

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.5.0

6 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.6

7 years ago

2.3.5

8 years ago

2.3.4

8 years ago

2.3.3

8 years ago

2.3.2

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.8

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

2.0.0-rc2

8 years ago

2.0.0-rc1

8 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago