duffelhq / duffel-api-javascript

JavaScript client library for the Duffel API

Home Page:https://duffel.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pagination in test mode

jose-dataka opened this issue · comments

Hi there, I am using a test token and I would like to know whether it exists any type of restriction in the number of pages, I am only receive one page in all requests.
Thanks for your time.

👋 Thanks for raising this question. To clarify what you're asking so that I understand it better, when you say "I am only receive one page" do you mean that you're only receiving a small amount of flight offers and you'd like to receive more offers for your search request(s) so that you can paginate through more than one page?

Hi there, right. I only received 50 records. But now we have changed the code and we don't use this module, we have integrated our own api rest module to get your data. Thanks.

Thanks for the clarification! Duffel's API supports pagination and you can control this through the listWithGenerator/0 function. An example of this pagination in action can be seen in

test('should get all offer requests paginated', async () => {
nock(/(.*)/)
.get(`/air/offer_requests`)
.reply(200, {
data: [mockOfferRequest],
meta: { limit: 1, before: null, after: null },
})
const response = new OfferRequests(
new Client({ token: 'mockToken' })
).listWithGenerator()
for await (const page of response) {
expect(page.data!.id).toBe(mockOfferRequest.id)
}
})
.

Beyond that, we're very interested to know what pain points you had with our library as we want to make it as easy to use as possible for our customers. If you'd rather discuss this privately, please get in contact with us via help@duffel.com so that we can continue the discussion.