DEV Community

loading...

Discussion on: Concept: High Performance web server w/ Promises

Collapse
mrm8488 profile image
Manuel Romero • Edited

Try this:

/* GET home page. */
router.get('/', function(req, res, next) {
  return new Promise(function(resolve, reject) {
    debug("GET /");
    resolve({ title: 'The Open Source U' }); //calculation or object
  })
  .then(function(payload) {
    res.render('site/index', payload)
  });
});
Collapse
theopensourceu profile image
Frank@theOpenSourceU.org Author • Edited

I'm replacing my previous comment about next. I think I see what you are pointing out. I'm revisiting this based on your feedback.