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

205
Visualizações
React - Fetch request stalls when receiving large Json array

In my app, I am trying to do a fetch request, save the incoming json array in state, and display this data in a table. This functionality works completely fine when the number of json objects in the array is about 200. However this array size can increase in size depending on filters selected in the app. When this array is over 600 for example, the request will hang and eventually will fail to return anything, giving error 502. Keep in mind, the data is received and displayed as it should if the array is smaller.

    fetch(URL, {
      headers: {
        "accept": "*/*",
        "Content-Type": "application/json",
      },
      method: "POST",
      body: JSON.stringify(searchBody),
    })
    .then(response => response.json())
    .then(data => {
      console.log(data)
      setSearchData(data);
    },
    (error) => {
      NotificationManager.error("Search Error");
      console.log(error)
  });

The above is the fetch request. I first tried to fix this by adding pagination to the table, however the error doesnt seem to be with the displaying but the response itself, as nothing is returned after sending the fetch. I cannot seem to find clear answers as how to limit the size of incoming response in chunks if that will solve the issue. Any help is greatly appreciated :)

about 4 years ago · Juan Pablo Isaza
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