title: Please suggest better way to write this code without making callback hell
body: <pre><code>router.get('/:id',ensureLogin,(req,res)=&gt;{
  
      somemodel.findOne({...}) ****//mongoose call 1****
      .then(result=&gt;{
     
          if(some condition){
              User.findOne(some condition) ***//mongoose call 2***
              .then(result=&gt;{
                   //Some code is to be executed here using the &quot;User.findOne...&quot;
                  }
                  res.render('some template')
              .catch(err=&gt;{
                  console.log(err)
              })
          }
          else{
              res.render('some another template');
          }
      })
      .catch(err=&gt;{
          res.render('error/500');
      })    
  })
  </code></pre>
  <p>Here mongoose call 2 depends on mongoose call 1 for some reason. Though the code is working yet I want it to be framed properly. So please suggest a better way for doing this. I hope I cleared enough the query.
  Thanks.
  PS: I'm a newbie in NODE.js</p>