Skip to content
Advertisement

NODEJS Getting data from database , then use them

i want to get data from database and array-loop That’s my actual structure. I have already test a tons of things without success

I’m open to any tips from you ! 🙂

EDIT : More information about database connection: myArray is like : [“a”,”*”,”b”,”myOwnMathFunction(a)”] but not important here Query : "SELECT * FROM User WHERE id='1' " //Verified & work

Advertisement

Answer

  • Use Array#map() to create multiple promises, e.g. from database queries.
  • Use Promise.all() to wait for multiple promises.
  • Use try/catch to handle success and error.

i.e.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement