I'm running a function that needs fetch data from API and push into an array the fetch is with in units loop
     var newArray = [];
        units.forEach((value) => {
            var discount = [];
            axios.get(baseApi() + `GetAllDiscounts?intUnitTypeId=${value.UnitTypeId}`, {
                headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Access-Control-Allow-Origin': '*' }
            }).then(response => {
                parseString(response.data, function (err, result) {
                    result.SSM.Record.forEach(function (content) {
                        if (content.DonotDisplay[0] === "False") {
                            discount.push({
                                discount_id: content.DISCOUNTID[0],
                                description: content.DISCOUNTNAME[0],
                                amount: content.Value[0],
                                typeText: content.CUSTOMERTYPE[0],
                                type: content.Type[0]
                            })
                        }
                    })
                })
            }).catch(error => { console.log(error) })
            console.log(discount)
            newArray.push({
                "ApproximateSize": value.ApproximateSize,
                "Breadth": value.Breadth,
                "CategoryName": value.CategoryName,
                "Discount": value.Discount,
                "InternetPrice": Math.round(value.InternetPrice),
                "InternetPriceAvailable": value.InternetPriceAvailable,
                "IsAvailable": value.IsAvailable,
                "Length": value.Length,
                "Rent": Math.round(value.Rent),
                "UnitTypeCode": value.UnitTypeCode,
                "UnitTypeDescription": value.UnitTypeDescription,
                "UnitTypeDetailedDescription": value.UnitTypeDetailedDescription,
                "UnitTypeId": value.UnitTypeId,
                // "discount_id": discount[0].discount_id,
                // "description": discount[0].description,
                // "amount": discount[0].amount,
                // "type": discount[0].type,
            })
        });
the result of discount array is [] but when I open array it contain one object also i check length it show 0 but it contain one array.
Note: I need signal object from api for every units

 
    