getArrayOrCsv #
Available since auto
Gets a parameter from the request arguments as an array, also accepting a comma-separated string.
This is the form the API documents for the ids argument of document:mGet, document:mExists and security:mGetUsers, and for the services argument of server:healthCheck.
- an array is returned as is;
- a string is, with the HTTP protocol only, first parsed as a JSON array (the way to pass an element containing a comma), and otherwise split on
,whatever the protocol.
Unlike getArray, a single value such as ?ids=foo is returned as ["foo"].
Arguments #
getArrayOrCsv (name: string, def: [] = null): any[]| Name | Type | Description |
|---|---|---|
name | string | Parameter name |
def | array | Default value to return if the parameter is not set |
Example #
// GET /_healthcheck?services=storageEngine,memoryStorage
const services = request.getArrayOrCsv('services');
// ["storageEngine", "memoryStorage"]