0

I'm calling function and return data push into an array but array is empty

property.forEach(function(proObj){
  var photo=[];
  proObj.photosId.forEach(function(Pid){
    fileUpload.fetchPhotoById(Pid,function(photoObj){
      photo.push(photoObj); //photo obj is added to photo Array
      console.log('source:-'+photoObj); // getting data correctly
    }) 
  })
  proObj.photos=photo;  
  console.log('Photo Array'+photo); // photo has default value means empty array
})

Please help me anyone to resolve

Sunil Chaudhary
  • 4,481
  • 3
  • 22
  • 41
veda
  • 71
  • 3
  • 12

0 Answers0