R
Reactiflux

✅ – Rinkusu – 17-54 Jun 20

✅ – Rinkusu – 17-54 Jun 20

LLaRynk6/20/2022
Hi, I'm having troubles assigning the value to this tmp value (it is undefined) outside the find call, any idea please ?
VVanishy6/20/2022
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
LLaRynk6/20/2022
Im using Mongo DB and toArray is just to format the data, forget the [0] thing, I have this much simpler to understand example:
VVanishy6/20/2022
does the first console.log even run?
LLaRynk6/20/2022
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:
VVanishy6/20/2022
looks like youre not awaiting in this code
LLaRynk6/20/2022
VVanishy6/20/2022
the only reason TMP OUT would print before IN is if you didnt await the promise
LLaRynk6/20/2022
yeah that's why I really don't understand why this aync await does not the job .
VVanishy6/20/2022
double check your code and run it again 🤷‍♂️
LLaRynk6/20/2022
I'm checking for an hour
LLaRynk6/20/2022
it just ignores the async/await
UUUnknown User6/21/2022
2 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

✅ – Rinkusu – 17-54 Jun 20

Join Server