Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
Using chained observables in transform pipe

I am facing issue while chaining observables in transform pipe. I have bank info with account number which is encrypted. I want to decrypt that account number and show.

In console it shows the decrypted account number but it displays only encrypted one. pls help

    public transform(bankId: any, name: string, args?: any): Observable<string> {
    return this.supService.getBankById(bankId).pipe(
      switchMap(
        (bInfo: {
        data: {
          bankInfo: {
            accno;
          };
        };
      }) => {
        if (bInfo.data.bankInfo.accno) {
          const encodedAccountNumber = bInfo.data.partyBankInfo.accountNumber;
          this.supService.unProtectBank(encodedAccountNumber).subscribe(
            (data: any) => {
              console.log("Unencrypted data======>", data);
              bInfo.data.bankInfo.accno = data;
          });
        }
        return of(bInfo);
      }),
      map(
        (info: {
          data: {
            bankInfo: {
              accno;
            };
          };
        }) => {
          console.log("Bank Info==============>", bankInfo);
            if (name === 'accountNumber') {
            return info.data.bankInfo.accno;
          }
        }
      )
    );
  }
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Your first switchMap operation returns of(bInfo) immediately without any chance for you inner call to finish and update the value.

What you need to do is replace the content of your switchMap with:

if (bInfo.data.bankInfo.accno) {
  const encodedAccountNumber = bInfo.data.partyBankInfo.accountNumber;
  // Do not subscribe here
  return this.supService.unProtectBank(encodedAccountNumber).pipe(
    map((data: any) => {
      console.log("Unencrypted data======>", data);
      bInfo.data.partyBankInfo.accountNumber = data;
      // Return something out of the Observable
      return bInfo;
    })
  );
} else {
  return of(bInfo);
}

The key thing here are the return statements and the removal of subscribe in favour of pipe.

over 4 years ago · Santiago Trujillo Denunciar

0

return the upProtectedBank Observable and use tap operator instead of subscribe.

switchMap(
        (bInfo: {
        data: {
          bankInfo: {
            accno;
          };
        };
      }) => {
        if (bInfo.data.bankInfo.accno) {
          const encodedAccountNumber = bInfo.data.partyBankInfo.accountNumber;
          return this.supService.unProtectBank(encodedAccountNumber).pipe(
            map((data: any) => {
              console.log("Unencrypted data======>", data);
              bInfo.data.bankInfo.accno = data;
              return bInfo;
          }));
        }
        return of(bInfo);
      }),
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda