I am fairly new to the world of Javascript promises and am having issues implementing the following:
var Promise = require('bluebird');
var jenkinsapi = require('jenkins-api');
var asyncJenkinsAPI = Promise.promisifyAll(jenkinsapi);
var jenkins = asyncJenkinsAPI.init("http://<user>:<password>@localhost:8080");
app.get('/api/servers', function(req, resp) {
    SavedJob.find({})
        .then(function(jobs) {
            return Promise.all(jobs.map(function(job){
                // do two calls with each job.name
                // build new data with the result of the two calls
                // return new data to next part of chain
                var job_status = jenkins.job_info(job.name, function(err, jobData) { return jobData; });
                var build_info = jenkins.last_build_info(job.name, function(err, buildData) { return buildData; });
                return {task_name: job_status.name,
                        status: STATUSMAP[job_status.color] || "UNKNOWN",
                        latest_build:
                            {
                                build_date: build_info.timestamp,
                                build_status: build_info.result,
                                build_number: build_info.number,
                                build_url: build_info.url
                            }
                        };
            }));
        })
        .then(function(results){
            console.log(results);
        });
    });
How can I best implement making two asynchronous calls inside the Promise.all() with each job.name and have the set of results at the end?
 
    