I have tried to find a guide how to get routes to work with variables in the url exemple : games/124512 and get that id to controllers in a variable.
My routes.js right now :
'/': {
view: 'homepage'
},
'/games/': {
controllers: 'games',
}
My GamesController.js right now :
var GamesController = {
sayHello: function (req, res) {
res.view('homepage', {
user : "sayHello",
});
},
sayWelcome: function (req, res) {
res.view('homepage', {
user : "sayWelcome",
});
}
};
module.exports = GamesController;
I can write /games/sayHello or /games/sayWelcome but what I would like is to be able to write exemple /games/234234 or /games/234234/settings
Thanks! :)
You can set url slugs in your routes like the link shows, i.e. /games/:id
. You can access them in your contoller via by name that you set in the route, i.e. req.param('id')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With