title: Error: Cannot set headers after they are sent to the client
body: <p>I code Promise.all , it load about 20 lines from db when running, it stops </p>
  
  <p>My code</p>
  
  <pre><code>router.get('/', (req, res) =&gt; {
    var cat = res.locals.lcCategories;
  
  Promise.all([postModel.getTop10View(),postModel.getTop10latest()]).then(data =&gt; {
      console.log(data);
      return res.render('home');
    }).catch(next);
  
  });
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
      at ServerResponse.setHeader (_http_outgoing.js:470:11)
      at ServerResponse.header (C:\Users\tranh\Desktop\Web2-News\node_modules\express\lib\response.js:767:10)
      at ServerResponse.send (C:\Users\tranh\Desktop\Web2-News\node_modules\express\lib\response.js:170:12)
      at done (C:\Users\tranh\Desktop\Web2-News\node_modules\express\lib\response.js:1004:10)
      at Immediate.&lt;anonymous&gt; (C:\Users\tranh\Desktop\Web2-News\node_modules\express-handlebars\lib\utils.js:26:13)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YNQS2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNQS2.png" alt="enter image description here"></a></p>