✅ – Rinkusu – 17-54 Jun 20

Hi, I'm having troubles assigning the value to this tmp value (it is undefined) outside the find call, any idea please ?
V
Vanishy668d ago
I dont know whats this .find/.toArray api, but its possible its not finding any values, so res is an empty array, and res[0] is undefined you can console.log(res) to confirm that
L
LaRynk668d ago
Im using Mongo DB and toArray is just to format the data, forget the [0] thing, I have this much simpler to understand example:
V
Vanishy668d ago
does the first console.log even run?
L
LaRynk668d ago
it print TMP OUT then TMP IN with the data, so it's a async problem here the thing is that that does not work:
V
Vanishy668d ago
looks like youre not awaiting in this code
L
LaRynk668d ago
V
Vanishy668d ago
the only reason TMP OUT would print before IN is if you didnt await the promise
L
LaRynk668d ago
yeah that's why I really don't understand why this aync await does not the job .
V
Vanishy668d ago
double check your code and run it again 🤷‍♂️
L
LaRynk668d ago
I'm checking for an hour
L
LaRynk668d ago
it just ignores the async/await
UU
Unknown User667d ago