I'm using axios.all to iterate through an array of items and send a GET request for each one in order to store their data correctly. Currently, I have an array of Promises that are all resolving with the right data, and the callback function triggers once they're all done.
Now, my next step is to loop through these Promises and save their values, but I'm having trouble accessing those values!
let promises = [];
for (let report of response.data.res.body.result) {
let dto2 = {
customerId: state.member.customerId,
reportToken: report.reportToken
}
promises.push(axios.post('http://localhost:3001/api/pullReport', dto2));
}
console.log("promises", promises);
axios.all(promises).then(function() {
console.log("done!");
promises.forEach(function(res) {
console.log("res", res);
// commit('SAVE_REPORT', res.value);
})
// resolve('Reports saved.');
});
When I console log each promise within the forEach loop, this is what it looks like:
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: Object <<<<<<<<<<< NEED THIS
All I need is to trigger the commit('SAVE_REPORT') function with the PromiseValue Object, but I can't figure out what to pass in! I've tried res.value, res.val, res.promiseValue... Is there some trick to this?