builder.getAll() issue in options {offset, limit}

Hi, I’m trying to fetch all my data from model but since the api have a limit in fetching the data, what I did was I tried to use the offset and limit options and put my codes in a loop where the offset just increments then put a checker for it to stop the loop when the api returns an empty array.

But my problem is that the api still returns data even though the offset already reached the full length/size of the data from a model.

For example, my model only has 40 records then I set the offset to something like 50. What I am expecting is that it will no longer return any data, but it still keeps on returning some data.
Did I set it up wrong?

Here’s my api key so you can simulate it from your end 5cde70e5453e4d12ba7e8c55a728859d

builder.getAll('blog', {
        offset: 50,
        limit: 40
    }).then(results => {
            console.log('result', results.length);
        });

Hi @manuel, thanks for reaching out! What framework are you using?

Hi Maddy, I’m using gatsby

Thanks for clarifying! I believe it may not be working as expected on your end because offset is not within options. Could you try adding offset within options (options: { offset: 50 })? Let me know if this gives the desired result.

Thank you for this post! Just helped me solve my issue with offset.

FYI the React SDK, GetContentsOptions interface has an offset property, which does nothing when used in the getAll() method. Your blog example shows the offset being set but it does not work. Thought I’d share so others don’t waste time on this and so that your documentation/SDK can be updated.

1 Like