1.0.1 • Published 8 years ago

legacy-req-param v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Legacy req.param

npm install legacy-req-param

https://nodei.co/npm/legacy-req-param.png?downloads=true

The familiar req.param() for express, as it is implemented in express 3 and 4. This got deprecated in express 4, so in case you don't agree with the deprecation rationale, and want to lose the deprecation warnings, this is for you.

Usage

app.use( require('legacy-req-param') )

Functionality

Returns the value of param name when present. req.param(name [, defaultValue])

// ?name=tobi
req.param('name')
// => "tobi"

// POST name=tobi
req.param('name')
// => "tobi"

// /user/tobi for /user/:name
req.param('name')
// => "tobi"

Lookup is performed in the following order:

  • req.params
  • req.body
  • req.query

Optionally, you can specify defaultValue to set a default value if the parameter is not found in any of the request objects.