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

Pagination #150

Open
tbtommyb opened this issue Oct 18, 2018 · 0 comments
Open

Pagination #150

tbtommyb opened this issue Oct 18, 2018 · 0 comments
Assignees
Labels

Comments

@tbtommyb
Copy link

Pagination in API responses is always really annoying to handle. It would be good to extract the logic for handling that since you have to use it a few times.

The processPage here seems like a useful starter.

Also, rather than

records.forEach(record => {
  caseTitles.push({
    title: record.get("case_title"),
    id: record.get("primary_key")
  });
});

You could try using map like:

caseTitles.push(records.map(record => ({ title: record.get('case_title'), id: record.get('primary_key')}))

Or similar (I haven't run the example). I think it makes the intent clearer, especially if you extracted the lambda in the map into something with a descriptive name.

@sima-qian sima-qian self-assigned this Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants