Judging by this and your other, similar thread, I’m guessing you’re not fully familiar with synchronous vs asynchronous code.
In your route, you’re treating db.getCustomers() as a synchronous operation - i.e. you’re expecting it to return a result before the rest of the code executes. However, the MongoDB client methods are asynchronous - when you call them, JS doesn’t wait for them to finish before moving on, which is why you have to provide a callback function (there are also other ways of dealing with async code).
You’ve got this right in your console.log() test - you just need to apply this to your route function.
which have given me a bettor grasp of things but still I have a lot to learn.
“You’ve got this right in your console.log() test - you just need to apply this to your route function.”
I know I have it right here but i’m actually clueless as how to add/rewrite this to work my routes routine, hence my cry for help here. I was hoping for a sample if you don’t mind .
I have tried a few different approaches but with my skill level i really need some help