nxus / router

The Nxus router is an Express compatible web server and router for Nxus applications.
MIT License
0 stars 0 forks source link

getRoutes() doesn't return useful route info #8

Closed ScottMaxson closed 8 years ago

ScottMaxson commented 8 years ago

The object returned by app.get('router').getRoutes() isn't expected.

This simple nxus module:

'use strict';

module.exports = function(app) {
  let router = app.get('router');

  router.setRoute('GET', '/', function(req, res) {
    res.send('router.getRoutes: ' + JSON.stringify(router.getRoutes()) );
  });
}

displays the following text on the page:

router.getRoutes: {"isFulfilled":false,"isRejected":false}

whereas we'd expect to see something like

[{method: "get", route: "/"} ...]

mjreich commented 8 years ago

@ScottMaxson that’s a promise signature. You’ll need to add a then like

router.getRoutes().then((routes) => {
  console.log(routes)
})
ScottMaxson commented 8 years ago

OK - thanks blush I guess one needs to read the core module and understand how the "app" object wraps other modules' functions?