# urlencoded-body-parser

> Small application/x-www-form-urlencoded request body parser

Latest version **3.0.0** (published 2019-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install urlencoded-body-parser
pnpm add urlencoded-body-parser
yarn add urlencoded-body-parser
bun add urlencoded-body-parser
```

## 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 | 3.0.0 |
| Published | 2019-07-03 |
| First published | 2016-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Tim Neutkens |
| Maintainers | timneutkens |

## Links

- npm: https://www.npmjs.com/package/urlencoded-body-parser
- Repository: https://github.com/timneutkens/urlencoded-body-parser
- Homepage: https://github.com/timneutkens/urlencoded-body-parser#readme
- Issues: https://github.com/timneutkens/urlencoded-body-parser/issues
- npm.io page: https://npm.io/package/urlencoded-body-parser

## Dependencies (3)

- [qs](https://npm.io/package/qs.md) ^6.2.1
- [raw-body](https://npm.io/package/raw-body.md) ^2.1.7
- [media-typer](https://npm.io/package/media-typer.md) ^0.3.0

## Recent versions

- 3.0.0 (latest) — 2019-07-03
- 2.0.1 — 2017-03-28
- 2.0.0 — 2017-01-08
- 1.0.1 — 2016-09-29

## README

# Urlencoded Body Parser

Small parser for [http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage) that turns `application/x-www-form-urlencoded` data into a javascript object using [qs](https://github.com/ljharb/qs).

### Api

`parse(req, {limit = '1mb'} = {})`

- Use `require('urlencoded-body-parser')`
- Returns a `Promise`
- Buffers and parses the incoming body and returns it.
- `limit` is how much data is aggregated before parsing at max. It can be a `Number` of bytes or [a string](https://www.npmjs.com/package/bytes) like `'1mb'`.
- The Promise is rejected when an error occurs

### Usage

Using [Micro](https://www.github.com/zeit/micro):

```js
const parse = require('urlencoded-body-parser')
module.exports = async function (req, res) {
  const data = await parse(req)
  console.log(data)
  return ''
}
```

Using build in HTTP server:

```js
const http = require('http');
const parse = require('urlencoded-body-parser')

const server = http.createServer((req, res) => {
  parse(req).then(data => {
    console.log(data)
    res.end();
  })
});

server.listen(8000);
```

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