title: node.js middleware making code synchronous
body: <p>I am trying to make <code>res.locals.info</code> available on every single page.
  I'm trying to do this by middleware but I'm getting an error.
  Apparently res.locals.info is not ready yet when the page render, thus I get an error <code>info is not defined</code>. How do I solve this?</p>
  
  <pre><code>  app.use(function(req,res,next){
  
    async function getInfo(user) {
  
      let result = await info.search(user);
      setInfo(result);
    }
  
  function setInfo(result){
  
    res.locals.info= result;
  }
  getInfo(req.user);
  
    return next();
  })
  </code></pre>
  
  <p>search():</p>
  
  <pre><code>module.exports.search= function (user) {
      var query=`SELECT count(*) as Info from dbo.InfoUsers WHERE user= '${user}' ;`
  
      return new Promise((resolve, reject) =&gt; {
      sequelize
          .query(`${query}`, {model: InformationUser})
          .then((info) =&gt; {
  
          resolve(info);
          })
      })
  };
  </code></pre>