Skip to content

Pagination #150

Description

@tbtommyb

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions