# dhttp

> Just another biased browserify-compatible HTTP/HTTPS wrapper

Latest version **3.0.3** (published 2018-12-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install dhttp
pnpm add dhttp
yarn add dhttp
bun add dhttp
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2018-12-20 |
| First published | 2015-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Daniel Cousens |
| Maintainers | dcousens |
| Keywords | dhttp |

## Links

- npm: https://www.npmjs.com/package/dhttp
- Repository: https://github.com/dcousens/dhttp
- Issues: https://github.com/dcousens/dhttp/issues
- npm.io page: https://npm.io/package/dhttp

## Dependencies (1)

- [statuses](https://npm.io/package/statuses.md) ^1.5.0

## Recent versions

- 3.0.3 (latest) — 2018-12-20
- 3.0.2 — 2018-11-28
- 3.0.1 — 2018-09-24
- 3.0.0 — 2018-09-24
- 2.5.0 — 2018-05-24
- 2.4.2 — 2018-01-31
- 2.4.1 — 2017-12-07
- 2.4.0 — 2017-11-13
- 2.3.6 — 2017-11-13
- 2.3.5 — 2017-05-16
- 2.3.4 — 2017-05-16
- 2.3.3 — 2017-04-26
- 2.3.2 — 2017-04-26
- 2.3.1 — 2017-02-09
- 2.3.0 — 2017-02-09
- … 22 more at https://npm.io/package/dhttp/versions

## README

# dhttp

[![TRAVIS](https://secure.travis-ci.org/dcousens/dhttp.png)](http://travis-ci.org/dcousens/dhttp)
[![NPM](http://img.shields.io/npm/v/dhttp.svg)](https://www.npmjs.org/package/dhttp)

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

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

``` javascript
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`](https://github.com/prettymuchbryce/node-http-status).

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

## LICENSE [MIT](LICENSE)

---
_Source: https://npm.io/package/dhttp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
