I am certain that this is super easy, but I can't for the life of me figure out why this does not work.
So trying to write an application where a user can search, gets a link, and if clocked it calls a second route, passing a variable while it is at it. Sounds simple, so thought I.
The idea is that each link generated gets a link like "localhost:3000/getcan/:[id]" So for our example, I am trying to get 22 into a variable if I try to go to webpage
"localhost:3000/getcan/:22"
To set up the route, I set the following in app.js
app.use('/getcan/:*', getcan);
This seems to work, and if I put anything that calls /getcan/: I go to the right route.
The route it self looks as follows
var express = require('express');
var router = express.Router();
/* GET getcan page. */
router.get('/', function(req, res, next) {
var canid = req.params.canid;
console.log("Got the following id " + canid)
res.render('getcan', { title: 'ResourceEdge', reqcan: canid });
});
module.exports = router;
I think the problem is with router.get('/' but if I make any changes (tried get('/getcan/:canid) it all blows up with a 404.
Any pointers?