✅ – 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 ?
![](https://cdn.answeroverflow.com/988502172117373018/unknown.png)
13 Replies
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 thatIm using Mongo DB and toArray is just to format the data, forget the [0] thing, I have this much simpler to understand example:
![](https://cdn.answeroverflow.com/988511268702937118/unknown.png)
does the first console.log even run?
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:
looks like youre not awaiting in this code
![](https://cdn.answeroverflow.com/988511671058300988/unknown.png)
the only reason TMP OUT would print before IN is if you didnt await the promise
yeah that's why I really don't understand why this aync await does not the job
.
double check your code and run it again 🤷♂️
I'm checking for an hour
![](https://cdn.answeroverflow.com/988522362221760565/unknown.png)
it just ignores the async/await
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/988502172759109653
This thread hasn’t had any activity in 12 hours, so it’s now locked.
Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/988502172759109653