How can I retrieve the value of dropVolume and use it in another method after executing my getAllDropsVolumePerDate(date) function? Each time I try to access dropVolume, it returns a value of 0.
dropVolume = 0;
getAllDropsVolumePerDate(date: string) {
this.campaignService.getAllCampaigns().subscribe((res) => {
res.forEach((campaign) => {
campaign.drops.forEach((drop) => {
if (drop.dropDate === date) {
this.dropVolume = this.dropVolume + drop.dropVolume;
}
});
});
return this.dropVolume;
});
return this.dropVolume;
}