Fetch all records from endpoint works but it's very slow.
I have a call to an api where I need to fetch all records under for a certain object and api number of records is about 39,000 records. The api has a limit of 1000 for pagination (I can't set the limit to 39,000 in one go). So I have to batch the calls to the api. Currently, the code I have is working and I'm able to pull all 39,000 records but this call is taking around 30 secs to a 1 min to finish. I was wondering how can I refactor the code below to 1) make it cleaner 2) more performant (In the ms or 1 territory versus 30s to 1min).
Any advice here?
Any advice here?