i dont know why this returned undefined. I google and something but dont find the result...
function getItemPrice(item_id) {
pool.query('SELECT item_price FROM bank WHERE item_id ='+item_id, function(err, row) {
console.log(row[0].item_price);
return row[0].item_price;
});
}
This shows the price in the console, that works.
But here it shows than undefined
items.forEach(function(itemObj){
var item_price = getItemPrice(itemObj.id);
console.log(item_price);
});
its a simple mysql query getting the price of an item