0

Sorry for bad English :)

I cannot import the data I send into 'ProductData' into 'ResponseData'. I wonder why?

In the 'Postman' application, I get a 'tree_products': [] return.

exports.Cnt_GetEventForGame = (req, res, next) => {
    var ResponseData = [];
    EventsModel.GetEventItems(req.params.id)
        .then(response => {
            for (var item in response[0]) {
                var ProductData = [];
                EventsModel.GetEventProducts(response[0][item].tree_id)
                    .then(response2 => {
                        for (var item2 in response2[0]) {
                            ProductData.push({
                                'product_id': response2[0][item2].product_id,
                                'product_order': response2[0][item2].product_order,
                                'product_name': response2[0][item2].product_name,
                                'product_path': response2[0][item2].product_path,
                                'product_version': response2[0][item2].product_version,
                            });
                        }
                    })
                    .catch(error => { console.log(error) });
                ResponseData.push({
                    'tree_id': response[0][item].tree_id,
                    'tree_name': response[0][item].tree_name,
                    'tree_path': response[0][item].tree_path,
                    'tree_model_path': response[0][item].tree_model_path,
                    'tree_products': ProductData
                });
            }
            res.status(200);
            res.json(ResponseData);
        }).catch(error => {
            console.log(error);
        })
}

0 Answers0