Trying to push product id into the array but it's not working! I tried different method using for and for each but no luck at all. it's to simple to not working properly
var preorder = new Array();
var order_items = new Array();
var items = req.body.line_items;
items.forEach(function(data) {
shopify.product.get(data.product_id)
.then(function(product){
console.log(product.id);
order_items.push(product.id);
})
.catch(err => console.error(err));
});
console.log(order_items);
Server Log
153161760794
89585614874
[]