fac-14 / OSCEBossKey

Weeks 13-16 > Tech for Better project: An app to help medical students revise for their exams
https://oscebosskey.herokuapp.com/
MIT License
3 stars 2 forks source link

Pagination #150

Open tbtommyb opened 5 years ago

tbtommyb commented 5 years ago

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.