I have the following function that does not return a value, my code is as follows
const getExpenseID = async () => {
try {
let newExpenseID=""
await Expenserequest.findMax(function(err,foundMax){
if (!err){
if (foundMax){
newExpenseID=parseInt(foundMax.expenseID)+1
}else{
newExpenseID =100
}
}else{
console.log(err)
}
})
console.log("found expense id in function",newExpenseID)
return newExpenseID
} catch (error) {
console.log(error);
}
}
when i call the function above it returns newExpenseId is blank