Contentful logo

Contentful Community

I need to split one call into 2 separeted calls becasue of the max size error from contentful

I have this call

@content = Contentful::Cover.load_children(5).params(“order” => “-fields.issue”).first

but i need to load 10 children and when i change 5 to 10 i’m getting this error

What the support team says was to split this call into 2 calls and then merge the responses and render it.

But my question is how do i filter the second content request to retrieve the next five elements from the content.

Is this make any sense?

Thanks

Hi @dev5,

You can do this by using the skip and limit paramater.

Let’s say you use order=-fields.issue&limit=2. That will retrieve the first 2 items of your query.

For the second request, you can then add skip=2 to skip these first 2 items, and retrieve the 3rd and 4th, as:

order=-fields.issue&limit=2&skip=2.

And then you just do this progressively until the end of the batch of items.

https://www.contentful.com/developers/docs/references/content-delivery-api/#/introduction/collection-resources-and-pagination

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/limit

1 Like

Hi @gabriel

Thanks for your replay, I’m dealing with another thing now, I’m doing this

res1 = Contentful::Cover.load_children(5).params(“order” => “-fields.issue”, limit: 5).first
res2 = Contentful::Cover.load_children(5).params(“order” => “-fields.issue”, limit: 5, skip: 5).first

but this objects res1 & res2 are a type of Contentful::Cover and I don’t know how to merge this two responses.

Do you have any clue of how i can do this?

Thanks