Action and search modules
Last updated
Last updated
Suppose you want to retrieve all users, that are registered on your service. You can’t use , because it returns only a single result. You will have to create a module for this.
The communication for is the same as for Action, except Search has an directive, which specifies where are the items located inside the body.
For the next example, suppose that when you call /users
on your service, you will get a list of users in body.data
.
This example will correctly output each user that was returned:
An module should never contain pagination
or the iterate
directive. If you need to return multiple objects, create a module instead.
The pagination
section should only contain parameters directly influencing the actual pagination. These will be merged with the rest of the parameters defined in the qs
section, so there is no need to define them all again.
The modules type Search and Trigger(polling) should return everything including by pagination. However, these modules should also allow users to limit their output, that is, how many bundles they return.
Search module limit example:
This can be achieved by setting up the parameter in the response. By default, this parameter is added to the Trigger (polling) modules and should be required. In Search modules, this parameter should NOT be required so if a user leaves it empty, the Search modules return everything. Its default value should be set to 10.