Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
How to automate taking X amount of items from array in a loop request

I have a large array filled with id's (array size will always be large, over 1000 for example) like this [000001,000002,000003,000004,...] and I want to send a request to an API that can contain up to 100 of these id's at a time (this is a limit, only 100 id's per request and out of my control)

The endpoint takes these id's as url params like so ?ids=000001,000002,000003,000004,... but I am struggling to figure out the logic I would need to perform to loop through every 100 entries and take those entries, send the request and then repeat until all entries have been added to a request?

This is my first question here on SO so apologies if this isn't quite the correct format, I just really need a logic check on this one...

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use JSON like this :

let createdJson = JSON.stringify(myIntArray);
// here send your request with :
sendRequest("http://url/?json=" + createdJson);

Then, in the other side you use something like :

In this example, I'm using PhP.

$intArray = json_decode($_GET["json"]);
// now you have your int array
about 4 years ago · Juan Pablo Isaza Report

0

The general principle would be to split your large array into chunks first, then form a request from each chunk, send it, wait for the reponse, keep hold of the results and then send the next.

Here's some code with no details:

const chunks = chunkArray(largeArray) // returns an array of arrays
let responses = []
for(const chunk of chunks){
    const query = createQueryStringFromArray(chunk)
    const response = await sendQuery(query) // post to API
    responses = [...responses, response] // keep hold of results
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!