AndersDJohnson / fetch-paginate

Get multiple pages from paginated APIs with fetch.
https://andersdjohnson.github.io/fetch-paginate/
MIT License
26 stars 4 forks source link

paging counter for second page is invalid #74

Open skydiablo opened 3 years ago

skydiablo commented 3 years ago

hi, based on this bundle https://unpkg.com/fetch-paginate@6.1.0/bundle.js the page query parameter isnt incrementing right. this is my code:

fetchOptions = {
//  ...
}

fetchPaginate.default('---URL---', {
                            fetchOptions: fetchOptions,
                            getItems: function (body) {
                                return body.rows
                            },
                            params: true,
                            page: 0,
                        })

the first request got the query param page=0, the second also and the third one got page=2. so the second page with page=1 is never called. bug?

regards, volker.

AndersDJohnson commented 3 years ago

@skydiablo I spent a little time digging into this but didn't find anything immediately that would explain. I have a feeling it could be due to some check for the truthiness or falsiness of 0. Are you able to tell from the source code what might be going on?

skydiablo commented 3 years ago

hmmm... TS is not my language, this a many fance stuff so i cant say what is going wrong... can you reproduce the issue?

AndersDJohnson commented 3 years ago

@skydiablo Sorry for the late response here. No, I don't think I've been able to reproduce yet. 🤔 Adding a unit test case to try to confirm/prove that the behavior is correct with page: 0 and params: true https://github.com/AndersDJohnson/fetch-paginate/pull/77.