In order to make the requests lighter Ordering API has included a request parameter called params
that serves to bring only specific data of a request. These attributes must be included in a string separated by commas as shown below:
For example, we want an order but we only want to know the products of that order and the driver so we use the following:
params:'products,driver_id'
https://apiv4.ordering.co/v400/en/demo/orders/6?params=products,driver_id
{
error: false,
result: {
id: 6,
driver_id: 9,
products: [...],
}
}
The parameters used in each request depend on the attributes of the model.
Using Ordering SDK
For this behavior there is the select(attributes: string[])
method, which is sent an array of the attributes that you want to bring.
Example:
const response = await ordering.orders().select(['products', 'driver_id']).get()