Http get multiple json files from different API endpoints using node express

I'm looking into the most efficient way to get multiple JSON files from different API endpoints using node.

Basically i'd like to store each JSON object in a variable, and send them all to Jade template files for parsing. I've got it setup working for getting one single JSON file (jsonFile1) by doing the following:

httpOptions = {
    host: 'api.test123.com',
    path : '/content/food/?api_key=1231241412',
    headers: {
        "Accept": "application/json",
        'Content-Type': 'application/json'
    },
    method: "GET",
    port: 80
}

var jsonFile1;

http.get(httpOptions, function(res) {
    var body = '';

    res.on('data', function(chunk) {
        body += chunk;
    });

    res.on('end', function() {
        jsonFile1= JSON.parse(body)
        console.log("Got response: " + jsonFile1);
    });
}).on('error', function(e) {
    console.log("Got error: " + e.message);
});

app.set('views', __dirname);

app.get('/', function(req, res) {
    res.render('home', {
        data: jsonFile1
    });
});

But i don't really want to have to repeat all of this to get multiple json endpoints and send them to home jade template.

Any ideas to do this efficiently?

Based on your code, this is a quick example using the excellent async library.

var async = require('async'),
    // Array of apis
    httpOptions = [
        {
            host: 'api.test123.com',
            path : '/content/food/?api_key=1231241412',
            headers: {
                "Accept": "application/json",
                'Content-Type': 'application/json'
            },
            method: "GET",
            port: 80
        },
            host: 'api.test234.com',
            path : '/content/food/?api_key=1231241412',
            headers: {
                "Accept": "application/json",
                'Content-Type': 'application/json'
            },
            method: "GET",
            port: 80
        }
    ];

// Put the logic for fetching data in its own function
function getFile(options, done) {
    http.get(options, function(res) {
        var body = '';

        res.on('data', function(chunk) {
            body += chunk;
        });

        res.on('end', function() {
            done(null, JSON.parse(body));
            console.log("Got response: " + jsonFile1);
        });
    }).on('error', function(e) {
        done(e);
        console.log("Got error: " + e.message);
    });
}


app.get('/', function(req, res) {
    // Map the options through the getFile function, resulting in an array of each response
    async.map(httpOptions, getFile, function (err, jsonFiles) {
        // You should probably check for any errors here
        res.render('home', {
            data: jsonFiles
        });
    });
});