Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda