Im a bit struggling to grasp promises, I have a use case when I perform X async actions, and when these are completed I make call to rest api. below my code:
const promises = defect.images.map(async image => {
return new Promise((resolve)=> {
this.fileProvider.getDefectImage(image.url)
.then(binary => {
images.set(image.url, binary);
resolve();
});
})
});
console.log(images)
return Promise.all(promises)
.then(() => spinner.dismiss())
but the console.log of images is always empty ... what should i change?
//edit sorry guys for leading into a trap, indeed this console.log can not work properly but Im not getting the data on bakcend side, its also empty there.