I want dropVolume get the value to use it in another method after calling my
getAllDropsVolumePerDate(date) method. but every time I get dropVolume = 0
this is my function :
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;
}
this is my getAllCampaigns() in the Campaign service :
getAllCampaigns() {
const campaigns = collection(this.firestoreDB, 'mail_campaign');
return from(
collectionData(campaigns, { idField: 'id' }) as Observable<Campaign[]>
);
}
Please any help ?