Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] How to implement this when I am using app.use and express.Router #18

Closed
warrenca opened this issue Apr 24, 2016 · 2 comments
Closed

Comments

@warrenca
Copy link

Here's my code and tests below, ty

var app = require("../app");
var express = require('express');
var router = express.Router();

var namedRouter = require('named-routes');
var namedrouter = new namedRouter();
namedrouter.extendExpress(app);
namedrouter.registerAppHelpers(app);

/* app.get is working but i am using
   app.use('/named', require('../routes/named'));
*/

app.get('/named/:name', 'named.name', function(req, res, next){
  var data = {name: req.params.name}
  res.render('named', data);
});

/* I actually want my code to be like the below but I am
   getting "Error: Route.get() requires callback functions but got a [object String]" */
/*
router.get(':name', 'named.name', function(req, res, next){
  var data = {name: req.params.name}
  res.render('named', data);
});*/

module.exports = router;

@alubbe
Copy link
Owner

alubbe commented Apr 25, 2016

Hi @warrenca
you can find out what is and is not possible in this discussion: #13
Let me know if that answers your question.

@warrenca
Copy link
Author

hi @alubbe, thanks for the info. i understood now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants