Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-param

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-param

Retrieve the request parameters from an incoming HTTP request

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

get-param

Safely retrieve the request parameters from an incoming HTTP request

Success Scenario

const { get } = require('get-param');

// Some middleware
(req, res, next) => {
  const param = get(req, 'myParam');

  // Example 1: Query Parameter
  // req = { query: { myParam: 'this is my query param' }};
  param === 'this is my query param'

  // Example 2: Body Parameter
  // req = { body: { myParam: 'this is my body param' }};
  param === 'this is my body param'

  // Example 3: Duplicate Parameter, defaults to body
  // req = { body: { myParam: 'this is my body param' }, query: { myParam: 'this is my query param' }};
  param === 'this is my body param'
}

Error Scenarios

const { get } = require('get-param');

// Some middleware
(req, res, next) => {
  const param = get(req, 'myParam');

  // Example 1: Parameter not defined
  // req = { query: { someOtherParam: 'this is my query param' }};
  param === false

  // Example 2: req not passed
  // req = undefined or null
  param === false
}

FAQs

Package last updated on 10 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc