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

125
Visualizações
Promises.all has null values when too many post requests sent

I am making a bunch of post requests to my API that will return some html/invoices, there are two scenerios where all the responses seem to be correct.

  1. When I send a small amount of requests.
  2. When I send a bunch requests, but the posted data is small in each one

However, when I post a high amount of requests with large bodies(e.g each post request contains an array of customer orders that is > 150), some of the promises return as null values.

Larger amount of requests results Small amount of requests result

With the returned data I want to generate a zipFolder full of invoices, but because some promises return null, some invoices are missing.

getSummaryInvoiceDetails() {
  this.zip = new JSZip();
  this.summary.forEach(element => {
    if (element.ShopId <= 50) {
      this.shopId = element.ShopId;
      this.invoiceData = mapInvoiceData(element);
      this.getOrderInvoiceDetails(element.ShopId);
      this.generateInvoice();
    }
  });
  this.zipInvoices();
},

async getOrderInvoiceDetails(shopId) {
  this.weeklyDetails.forEach(element => {
    if (element.shopId === shopId) {
      const obj = {};
      obj.OrderRef = element.ref;
      obj.Contact = element.name;
      obj.OrderTotal = element.ordeR_TOTAL;
      obj.DeliveryCharge = element.deliverY_CHARGE;
      obj.PaymentMethod = element.payment;
      obj.OrderTime = element.ordeR_TIME;
      this.invoiceData.Orders.push(obj);
    }
  });
},

async zipInvoices() {
  // Zip files when all invoices generated/promises resolved
  const res = await Promise.all(this.promiseArray);
  console.log(res);
  res.forEach(element => {
    let shopName = '';
    try {
      shopName = this.invoiceNameArray[this.x];
      const blob = new Blob([element.data], { type: 'text/plain;charset=utf-8' });
      this.zip.file(`${shopName}.html`, blob);
    } catch (err) {
      console.log(shopName);
    }
    this.x += 1;
  });
  this.zip.generateAsync({ type: 'blob' })
    .then(content => {
      FileSaver.saveAs(content, 'Invoices.zip');
    });
},

async generateInvoice() {
  const result = this.getInvoice(this.invoiceData);
  this.invoiceNameArray.push(this.invoiceData.ShopName);
  this.promiseArray.push(result);
},

This is the type of data in body of the post request

My project is in Vue.js and the backend is dotnet core

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