Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda