Skip to content
Advertisement

Node JS multliple promises chaining

I have node JS api server and I’m having issues with correct chaining of the Promises:

JavaScript

What I get in console is :

  • 1 [Object] – all good
    1. Emppty Array
    1. Empty Array
  • get one doc {object} – all good
  • 1.5 {object} – all good

How would I make sure when I loop over result of 1st promise my code awaits async function and pushes to newArray results ?

Advertisement

Answer

Use For..of instead of forEach inside arrayToDoc function

E.g

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