Estoy haciendo un montón de solicitudes de publicación a mi API que devolverán algunos html/facturas, hay dos escenarios donde todas las respuestas parecen ser correctas.
Sin embargo, cuando publico una gran cantidad de solicitudes con cuerpos grandes (por ejemplo, cada solicitud de publicación contiene una matriz de pedidos de clientes que es> 150), algunas de las promesas regresan como valores nulos.
Gran cantidad de resultados de solicitudes Pequeña cantidad de resultados de solicitudes
Con los datos devueltos, quiero generar una carpeta zip llena de facturas, pero debido a que algunas promesas devuelven un valor nulo, faltan algunas facturas.
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); },Este es el tipo de datos en el cuerpo de la solicitud de publicación.
Mi proyecto está en Vue.js y el backend es dotnet core