0

i used to use the generator function, and it is really easy to use. when i want to do multiple asynchronous calls, i just simple use code like this

// all calls will be execute in the same time (no wait)
const resultA = yield callServiceA()
const resultB = yield callServiceB()
const resultC = yield callServiceC()

if (resultA && resultB && resultC) {
  // we got results from all services now, 
}

how to migrate the code above to use async and await keyword on node.js version 7 or above

josh3736
  • 139,160
  • 33
  • 216
  • 263
Alongkorn
  • 3,968
  • 1
  • 24
  • 41

0 Answers0