Order
The "Order" params is the simplest way to sort items in your GET all responses. The most common use is when you want Sorting in ascending or descending order the response.
Params
Key | Value |
order | <PARAMETER_ID>;asc |
Use the asc/desc
key and the parameter ID to define the order.
Response samples for ASC "order"
GET
/api/lib/{arke_id}/unit
order=label;asc
{
"content": {
"count": 10,
"items": [
// Ascending sort by label
{
"id": "active",
"label": "Active",
...
},
{
"id": "code",
"label": "Code",
...
}
{
"id": "id",
"label": "ID",
...
},
],
}
"messages": []
}
Response samples for DESC "order"
GET
/api/lib/{arke_id}/unit
order=label;desc
{
"content": {
"count": 10,
"items": [
// Descending sort by label
{
"id": "id",
"label": "ID",
...
},
{
"id": "code",
"label": "Code",
...
}
{
"id": "active",
"label": "Active",
...
},
],
}
"messages": []
}
Multiple order
If you need multiple sorting you can use an array of order params:
[{order: 'name;desc'},{order: 'date;asc'}]
Use a paramsSerializer
to stringify the array in the request
On params we'll have a definition as:
order[]=name%3Bdesc&order[]=date%3Basc