inputs
object.rawEmployees
and searchString
, both of which are bound to page variables with the same keys. These values are then available under inputs.rawEmployees
and inputs.searchString
.inputs
object remains as the "snapshot" taken at the beginning of execution.filteredEmployees
output schema is provided just an array of objects for brevity. In reality, we should explicitly define what properties the objects in the array are expected to have, e.g. firstName
and lastName
and so on.) inputs
object, e.g. inputs.rawEmployees
and inputs.searchString
in the code above.filter
function on the inputs.rawEmployees
array, checking if our search string matches either the first name or last name of the employee.return
statement. What we return should always be an object whose properties match what we've defined for our output arguments. filteredEmployees
property contains the filtered data.[index, returnObject]
where index
is the index number of the desired output (starting from 0
) and returnObject
is an object whose properties match the output arguments defined for the given output.fetch
and moment
are currently exposed in the runtime context.async
function, so you can use the await
keyword on the root level directly.
Below is an example where we also implement error handling with try-catch
: