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.
req.allParams();
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) {
// ...
});
- 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 usereq.allParams()
in favor ofreq.params.all()
to avoid such a situation.