Using an API for Data in our Pages
Learn how to use Node.js, Express.js and Nunjucks to create dynamic web applications
GET /film/:id Route Handler
app.get('/film/:film', function(req, res) {
let apiKey = 'your-key;
fetch('http://www.omdbapi.com/?apiKey=' + apiKey + '&i=' + req.params.film)
.then(function(data) { return data.json(); })
.then(function(film) {
console.log(film);
res.render('film.html', {
film: film
});
})
});
Need help? Have questions? Join the Vonage Developer Community Slack and use the channel #onehack.