Skip to main content

Working with OData

To change how you receive data from backend add ODataConfig. You can create it with ODataBuilder:

const oDataConfig = getODataBuilder()
.top(10) // Get first 10 items
.select("name") // Select only name property
.filter("name", "Adam") // Filter student only with name Adam
.orderBy("name", "asc") // Order students by name property in ascending direction
.build();

Using ODataBuilder you can customize api requests:

On frontend

Now you can use this config in functions like fetchResources():

const students = await fetchResources<Student>("Student", oDataConfig);

On backend

You can also use this config on the backend with getResourcesWithOData():

const students = await getResourcesWithOData<Student>("Student", oDataConfig);