contentful-management.js icon indicating copy to clipboard operation
contentful-management.js copied to clipboard

Total items count

Open nenadg opened this issue 3 years ago • 1 comments
trafficstars

Hi, is there a method that will return the total items count. I'm having a problem once the total number of items in response reach the response limit. So I would need total number of items to implement paging-like behavior.

  sys: { type: 'Error', id: 'BadRequest' },
  message: 'Response size too big. Maximum allowed response size: 7340032B.',
  requestId: 'blahblah'
}

nenadg avatar Aug 17 '22 16:08 nenadg

Hey @nenadg .

It is a bit unclear what exactly request you are sending, but usually, you should be able to get the total number if you add ?limit=0 to the request. Then you will not hit the response size limit, because the response will not have any data, but also you should be able to see the total number of entities you are trying to fetch

Spring3 avatar Sep 23 '22 09:09 Spring3

Hi @Spring3, sorry for not reaching earlier. I'm using contentful-management, so in the end my request would look something like this:

await client.getEntries({
      
      content_type: contentType,
      /* ... what else goes here to get total items count? */
    })

I've tried setting limit: 0 but that didn't yield total number of entries. Thanks!

nenadg avatar Oct 04 '22 10:10 nenadg

I have made some quick requests and I got the total number of entries without all the data for each entry.

For a specific content type: Screenshot 2022-10-26 at 21 29 58

Total amount of entries no matter the content type Screenshot 2022-10-26 at 21 32 55

Spring3 avatar Oct 26 '22 19:10 Spring3

Thanks, this resolves my issue.

nenadg avatar Jan 13 '23 08:01 nenadg