# Sdk: how to perform a single request to get data and aggregate count?

**URL:** <https://community.directus.com/t/sdk-how-to-perform-a-single-request-to-get-data-and-aggregate-count/347>\
**Category:** Help\
**Tags:** api\
**Created:** [May 16, 2025, 1:03pm UTC](https://community.directus.com/t/sdk-how-to-perform-a-single-request-to-get-data-and-aggregate-count/347 "2025-05-16T13:03:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yves852](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/yves852/32/318_2.png) [@Yves852](https://community.directus.com/u/Yves852)\
**Post date:** [May 16, 2025, 1:03pm UTC](https://community.directus.com/t/sdk-how-to-perform-a-single-request-to-get-data-and-aggregate-count/347/1 "2025-05-16T13:03:38Z")

</div>

Hello folks.

For a index news page, with a rest call I would use meta=filter\_count in the same request like the following:

```ts
  const data = await $fetch(`url.com/items/news
?sort=-date_created
&filter[status][_eq]=published
&fields=slug,title,date_created
&sort=-date_created
&page=${pageNum}
&limit=${limit}
&meta=filter_count`)

// {
// data: [...],
// meta { filter_count },
// }

```

But right now I can’t figure out how to perform a single request with the sdk to get a similar result.

Right now I’m doing with two ‘readItems’ requests similarly to this:

```ts
  const pageNum = 1
  const limit = 10
  let data = null
  let count = 0

  try {
    // Request count
    count = await directus.request<number>(
      readItems('news', {
       aggregate: { count: '*' },
        filter: {
          status: 'published',
        },
        page: pageNum,
        limit,
      }),
    )
    // Request data
    data = await directus.request(
      readItems('news', {
        filter: {
          status: 'published',
        },
        page: pageNum,
        limit,
        sort: ['-date_created'],
        fields: ['slug', 'title', 'date_created'],
      }),
    )
  }
  catch (e) {
    console.error(e)
  }

  const result = {
    count: count?.[0]?.count,
    data,
  }

  return result

```

Using `"@directus/sdk": "^19.1.0"` and `"nuxt": "^3.17.3"`.

My apologies if the answer is trivial. Thanks for your help. 🙏

---

<div class="post-metadata">

**Author:** ![ahmad\_quvor](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/ahmad_quvor/32/310_2.png) [@ahmad\_quvor](https://community.directus.com/u/ahmad_quvor)\
**Post date:** [May 16, 2025, 1:14pm UTC](https://community.directus.com/t/sdk-how-to-perform-a-single-request-to-get-data-and-aggregate-count/347/2 "2025-05-16T13:14:43Z")

</div>

This isn’t possible in a single request. You’ll need to make two separate requests: one to fetch the data and another to get the count.

---

<div class="post-metadata">

**Author:** ![Yves852](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/yves852/32/318_2.png) [@Yves852](https://community.directus.com/u/Yves852)\
**Post date:** [May 16, 2025, 1:20pm UTC](https://community.directus.com/t/sdk-how-to-perform-a-single-request-to-get-data-and-aggregate-count/347/3 "2025-05-16T13:20:14Z")

</div>

I understand. Thank you for the fast response.

Is there a chance it will be implemented in the future? Should I create a feature request or maybe one was already created/rejected?
