0

Actually I need to do execute var1 before var2 in angular Please let me know how I can achieve this. Thanks for your help

let var1 = Promise.resolve(database.query(sql))
          .then((res) => {
               someVar = res;
               return someVar;
}))

let var2 = Promise.resolve(database.query(sqlanother)){
          .then((resanother) => {
               someanotherVar = resanother;
               return someVaranother;
}))


Yud S
  • 11
  • 2
  • Does this answer your question? [Resolve promises one after another (i.e. in sequence)?](https://stackoverflow.com/questions/24586110/resolve-promises-one-after-another-i-e-in-sequence) – Beshambher Chaukhwan Jun 02 '21 at 02:24
  • Actually I was not able to resolve it sequentially. Was getting undefined if I use someVar in var2 @BeshambherChaukhwan – Yud S Jun 02 '21 at 02:37
  • Please dont use angular and angularjs tags in the same question. Kindly remove one – Owen Kelvin Jun 02 '21 at 02:58
  • Wit brackets and curly braces out of balance, it is hard to know what you have actually tried. What does `database.query()` return? Is it `Promise`? – Roamer-1888 Jun 02 '21 at 18:16

0 Answers0