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.
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
processPagehere seems like a useful starter.Also, rather than
You could try using
maplike: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.