Skip to content

snird/req-param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

req.param()

npm install req-param

https://nodei.co/npm/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('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.

About

the req.param() function for express, as implemented in express 3&4, without deprecation warnings

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published