Edit Page

req.allParams()

Returns the value of all parameters sent in the request, merged into a single dictionary (plain JavaScript object). Includes parameters parsed from the URL path, the request body, and the query string, in that order. See req.param() for details.

Usage

#
req.allParams();

Example

#

Update the product with the specified sku, setting new values using the parameters that were passed in:

var values = req.allParams();

// Don't allow `price` or `isAvailable` to be edited.
delete values.price;
delete values.isAvailable;

// At this point, `values` might look something like this:
// values ==> { displayName: 'Bubble Trouble Bubble Bath' }

Product.update({sku: sku})
.set(values)
.exec(function (err, newProduct) {
  // ...
});

Notes

#
  • The order of precedence means that URL path params override request body params, which will override query string params.
  • In past versions of Sails, this method was known as req.params.all(), but this could be confusing—what if you had a route path parameter named "all"? In apps built on Sails v1 or later, you should use req.allParams() in favor of req.params.all() to avoid such a situation.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

Reference