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

124
Views
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
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!