I have a function that calls an exported async/await function I need to push the value returned in an array and return it but I get an empty array I know I have to use a promise but can't figure out how to do it correctly.
function calculatePrice() {
let nearestPickUps = findNearestPickups();
let prices = [];
nearestPickUps.forEach(loc => {
let pickup = loc.nearest.pickup;
calcPrice
.getPriceList()
.then(function(result) {
prices.push(result); // push to array
console.log(result); // value is retured
});
});
return prices; // returns empty array
}