1. Vonage Learn
  2. Courses
  3. Onehack
  4. Node
  5. Third Party Data in Pages

Using an API for Data in our Pages

Learn how to use Node.js, Express.js and Nunjucks to create dynamic web applications

OMDb API

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.