getBodyNumber #
Available since 2.16.9
Gets a parameter from the request body and checks that it is a number. We also support lodash syntax. (relations.lebron[0]
)
Arguments #
getBodyNumber (name: string, def: number = null): number
Name | Type | Description |
---|---|---|
name | string | Parameter name |
def | number | Default value to return if the parameter is not set |
Example #
const age = request.getBodyNumber('age');
// equivalent
const age = request.input.body.age;
//+ checks to make sure that "age" is of the right type
// and throw standard API error when it's not the case
Edit this page on Github(opens new window)