title: How do i nest a promise inside another promise function in node.js?
body: <p>I have a file file which is surrounded by Promise function . I have a database operation inside this function which requires another promise too . Please check the code below</p>
  
  <pre><code>var p ;
  var ted = dep.map(function(name){
  
  return new Promise(function(resolve,reject){ 
      /*..list of other tasks*/
      for(int i = 0 ;i&lt;3&lt;;i++){        
        p = Promise.resolve(savemongo(myobj,str));  // this is async function. How do I wait till this operation is complete and then move to next
      } 
    resolve();
  
  )};
  </code></pre>
  
  <p>Now i have to export this module to a different file </p>
  
  <p>Im using the below code </p>
  
  <pre><code>module.exports = Promise.all([ted,p]);
  </code></pre>
  
  <p>How do I wait till my savetomongodb function is complete . </p>