Returning the values inside Promise.all
Hi I am writing a function to load the values from the three promises into an array but I cant seem to work around getting the values from outside the promise.
Need the values field from the callback.
Has anyone found a way to work through this.
var firstPromise = s3.getObject({Bucket: bucket, Key: key1}).promise()
.then(function(data){
return data;
})
.catch(function(err) {
console.log(err);
});
var secondPromise = s3.getObject({Bucket: bucket, Key: key2}).promise()
.then(function(data){
return data;
})
.catch(function(err) {
console.log(err);
});
var thirdPromise = s3.getObject({Bucket: bucket, Key: key3}).promise()
.then(function(data){
return data;
})
.catch(function(err) {
console.log(err);
});
Promise.all([firstPromise, secondPromise, thirdPromise])
.then(function(values){
logger.debug("Value 0 is " + values[0].Body.toString());
logger.debug("Value 1 is " + values[1].Body.toString());
callback(null,values);
});