0
votes

I have documents id in the Information I am getting from service. I need documents Info to be attached to this parent information and return parent. Not able to return observables in loop. The second switch map is working fine. The first is not executing if I return tInfo from map it gives following error

Argument of type '(tInfo: { documents; documentsInfo: any[]; }) => void' is not assignable to parameter of type '(value: { documents: any; documentsInfo: any[]; }, index: number) => ObservableInput'. Type 'void' is not assignable to type 'ObservableInput'

public transform(tId: any,name: string, args?: any): Observable<string> {
return this.sService.getTaxById(tId).pipe(
  // tslint:disable-next-line: deprecation
  switchMap((tInfo:{ documents ; documentsInfo: any [] }) => {
    if (tInfo.documents) {
      tInfo..documents.forEach(doc => {
        return this.sService
          .getFiles(doc.docId).pipe(
            map((filesInfo: { FileName: ''; downloadUrl: '' }) => {
                      const fileObjnew =
                        {
                          docName: filesInfo.FileName,
                          downloadUrl: filesInfo.downloadUrl,
                        }
                        tInfo.documentsInfo.push(fileObjnew);
                    })
          );
      });
     return of(taxInfo);
    }
  }),
  // tslint:disable-next-line: deprecation
  switchMap((Info: { cc: '' ; authority: '' ; cName: ''}) => {
    if (Info.authority) {
      const cc = taxInfo.cc;
      return this.sService.getOrgs(cc).pipe(
        map((orgsData: any) => {
          console.log("Data============>", orgsData);
          (orgsData || []).forEach(tax => {
            if (orgsData.aid === tax.id) {
              Info.cName = tax.parentName;
            }
          });
          return Info;
        })
      );
    }
  }),
  map((Info) => {
    if (name === 'subsTemplate') {
      return this.subsTemplate(Info);
    }
  })
);

}

You can subscribe to your observable to access it's value and assign it - Noxin D Victus
Nope Subscribe is not executing for getFiles service - Gaurav Matta