# send-data

> send data through response

Latest version **8.0.0** (published 2015-10-20) · 0 weekly downloads

## Install

```sh
npm install send-data
pnpm add send-data
yarn add send-data
bun add send-data
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2015-10-20 |
| First published | 2012-09-23 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Raynos |
| Maintainers | raynos, jwolski |

## Links

- npm: https://www.npmjs.com/package/send-data
- Repository: https://github.com/Raynos/send-data
- Issues: https://github.com/Raynos/send-data/issues
- npm.io page: https://npm.io/package/send-data

## Dependencies (2)

- [xtend](https://npm.io/package/xtend.md) ^4.0.0
- [json-stringify-safe](https://npm.io/package/json-stringify-safe.md) ^5.0.0

## Recent versions

- 8.0.0 (latest) — 2015-10-20
- 7.0.0 — 2015-04-01
- 6.0.0 — 2015-02-11
- 5.0.0 — 2015-01-20
- 4.0.1 — 2015-01-20
- 3.3.4 — 2015-01-06
- 3.3.3 — 2014-08-19
- 3.3.2 — 2014-08-10
- 3.3.1 — 2014-07-30
- 3.3.0 — 2014-07-29
- 3.2.5 — 2014-07-15
- 3.2.4 — 2014-06-08
- 3.2.3 — 2014-06-08
- 3.2.2 — 2014-06-08
- 3.2.1 — 2014-06-08
- … 18 more at https://npm.io/package/send-data/versions

## README

# send-data [![build status][1]][2]

send data through response

Originally taken from [npm-www](https://github.com/isaacs/npm-www)

## Example

```js
var send = require("send-data")
var sendJson = require("send-data/json")
var sendHtml = require("send-data/html")
var sendError = require("send-data/error")
var http = require("http")

http.createServer(function handleRequest(req, res) {
    if (req.url === "/send") {
        send(req, res, {
            body: "foo",
            statusCode: 202,
            headers: {
                bar: "baz"
            }
        })
    } else if (req.url === "/optional") {
        send(req, res, "foo")
    } else if (req.url === "/json") {
        sendJson(req, res, {
            body: {
                foo: "bar"
            },
            statusCode: 201
        })
    } else if (req.url === "/json/optional") {
        sendJson(req, res, {
            foo: "bar"
        })
    } else if (req.url === "/html") {
        sendHtml(req, res, {
            body: "<div>foo</div>",
            statusCode: 200,
            headers: {}
        })
    } else if (req.url === "/html/optional") {
        sendHtml(req, res, "<div>foo</div>")
    } else if (req.url === "/oops") {
        sendError(req, res, { body: new Error("OOPS") })
    }
}).listen(8080)
```

## Installation

`npm install send-data`

## Tests

`npm test`

## Contributors

 - Raynos

## MIT Licenced

  [1]: https://secure.travis-ci.org/Raynos/send-data.png
  [2]: http://travis-ci.org/Raynos/send-data

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