0.1.0 • Published 6 years ago

@body/urlencoded v0.1.0

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

URL-encoded body parser

Parse an URL-encoded body of an incoming HTTP request.

Installation

npm install --save @body/urlencoded

Usage

const getUrlencodedBody = require('@body/urlencoded')

// ...

app.post('/v1/users', async (req, res, next) => {
  try {
    const body = await getUrlencodedBody(req)

    // ...
  } catch (err) {
    return next(err)
  }
})

// ...

API

getUrlencodedBody(req: Request, options: Options): Promise<any>

Parse the body of the incoming request req. Returns a promise of the parsed body.

Options

inflate (boolean)

When set to true, then bodies with a deflate or gzip content-encoding will be inflated before being parsed.

Defaults to false.