dhttp v3.0.3
dhttp
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
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
