DEV Community

Discussion on: Using MongoDB with Node.JS

Collapse
 
juliannicholls profile image
Julian Nicholls

Allowing for the fact that I haven't tried this code...

Shouldn't the

const res = readListing('question', 'questions', {
    answer: guess
});
Enter fullscreen mode Exit fullscreen mode

be

const res = await readListing('question', 'questions', {
    answer: guess
});
Enter fullscreen mode Exit fullscreen mode

because readListing() is an async function.

Collapse
 
peppermints profile image
Pepper.

Yes haha, I completely forgot about this. Thank you!

Collapse
 
logicmirror profile image
LogicMirror

For me it didn't work with the async but did once I took it out.

Thread Thread
 
peppermints profile image
Pepper.

It should work, and it is supposed to be async- but if it works for you then that'd fine! Enjoy :)