Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to paginate in Node #3

Closed
AnalogJ opened this issue Sep 14, 2018 · 4 comments
Closed

How to paginate in Node #3

AnalogJ opened this issue Sep 14, 2018 · 4 comments

Comments

@AnalogJ
Copy link

AnalogJ commented Sep 14, 2018

Hey,
I'm trying to determine how to pass a page querystring parameter when requesting a list of repositories.

@MunifTanjim
Copy link
Owner

MunifTanjim commented Sep 15, 2018

I don't know which API you're trying to use, but something like this should work:

bitbucket.repositories
  .list({ username: 'MunifTanjim' })
  .then(({ dataPage1, headers }) => {
    console.log(dataPage1)

    bitbucket
      .getNextPage(dataPage1)
      .then(({ dataPage2, headers }) => {
        console.log(dataPage2)
      })
      .catch(err => console.error(err))
  })
  .catch(err => console.error(err))

Does this help?

@AnalogJ
Copy link
Author

AnalogJ commented Sep 16, 2018

unfortunately not.

I'm using this library in a node backend API that's returning paginated data to a AngularJS client side application. The AngularJS app displays the content, and supports paginated requests to the backend api.

basically I need to do something like:

bitbucket.repositories
  .list({ username: 'MunifTanjim', page: 2 })
  .then(({ dataPage2, headers }) => {
    console.log(dataPage2)
  })
  .catch(err => console.error(err))

It's possible using the octokit.rest library, and I was hoping I could do the same with yours.

@MunifTanjim
Copy link
Owner

MunifTanjim commented Sep 16, 2018

@AnalogJ That should resolve the issue.

The npm package will soon be updated with these changes as version 1.2.0

npm package updated: bitbucket@1.2.0

Cheers 🎉

@AnalogJ
Copy link
Author

AnalogJ commented Sep 16, 2018

Thats exactly what I needed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants