Using Route Parameters
Learn how to use Node.js, Express.js and Nunjucks to create dynamic web applications
GET /films/:film Route Handler
app.get('/films/:film', function(req, res) {
console.log(req.params.film);
// Returns first item that matches criteria
let film = films.find(function(film) {
return film.id == req.params.film;
});
res.json(film);
// Try http://localhost:3000/films/tt2090440
});
Need help? Have questions? Join the Vonage Developer Community Slack and use the channel #onehack.