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