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

164
Vistas
behaviourSubject returns [object][object] when its subscribed

Im working with a bank API for the payment.what banks want to response is he Ban Pay JavaScript will perform an HTTP redirect in the top frame to the completeUrl. what completeUrl the url i should give the bank api to send their response.in my app.component.ts

          this.http.post("BankEndURL",quote,).subscribe(s=>{
    //here i get quote 
      this.newpay=s;
      
      //here im passing the paymentID to my service in angular to store there,because 
            at the end of the transaction ,if its successful i need it to show the transaction data
            this.dataService.setData(s);
       //here i send a quote to backend to give me a bankurl with payment data
       this.http.post("SecondBakednURL",this.newpay).subscribe(s=>{
     
         this.payaddress= s['reDirectAuthorizationHref'];
         //here i open the url to redirect the user to the payment portal
          window.open(this.payaddress);

here is the service i have created :

public sharedData = new BehaviorSubject<any>(null);

constructor() {}

  getData(){   
  return this.sharedData;
       }

setData(data:any){
this.sharedData.next(data);
}

and here is my receiver component,the one which the bank will hit it once the transaction is successful,im going to show the transction data of the user

        constructor(private dataService:DataService) {}

      ngOnInit(): void {
        this.dataService.getData().pipe(
          filter(data => !!data)
        ).subscribe(data => {
          alert(data)
        });

but data here returns null

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In this case, getSharedData() returns the behavior subject itself, so the sensible thing to do in this case is to subscribe to it in order to receive the data that you are emitting when calling setData.

In the receiver component:

ngOnInit(): void {
  this.dataService.getData().pipe(
    filter(data => !!data)
  ).subscribe(data => {
    alert(data)
  });
}
about 4 years ago · Juan Pablo Isaza 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