Skip to main content

Query

This service belongs to the OVP layer and it is responsible for treating queries and performing requests to the OVP. It is also in charge of returning modelized data.

Details

For queries we are following the double curly braces template convention: /categories/{{category}}/movie

Available methods:

getItemsByQuery({ query, contextData, numberOfElements = 15, sortBy = ''}): interpolates the query with the parameters data and perform the request to the OVP provider.

Associated Models:

This service uses the Item model for parsing and models data. If your OVP returns any different attribute, please, remember to update the model to get the correct value.

Example

const getItemsByQuery = async ({ query, contextData }) => {
const interpolatedQuery = contextData
? query.replace(/\{\{(\w+)\}\}/g, () => contextData)
: query;
const items = await fetcher({
cacheId: `${PROVIDER_TYPE.ovp}-query-${interpolatedQuery}`,
fetchFn: () => ovp.getItemsByQuery({ query: interpolatedQuery })
});

return items.map(item => Item(item));

Note: your OVP provider implementation must have the method ovp.getItemsByQuery