Hi there, I’m trying to optimize my code, because currently, I have a request to get all entries of a model and then return the data.results.length
Is there a way to request only to get the count given a field?
this is my current code:
const getCategoryCountApi = async (categoryKey: CategoryId) => {
const params = {
apiKey: $runtimeConfig.public.BUILDER_IO_MARKTPLATZ_API_KEY,
"query.data.categories.category.$in": [categoryKey],
limit: 1000,
"query.published": "published",
}
const response = await axiosClient.get(`${$runtimeConfig.public.BUILDER_IO_ENDPOINT_URL}/marktplatz-offers`, { params })
if (response && response.data && response.data.results) {
return response.data.results.length
}
return 0
}
API_KEY =
thanks