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

389
Vistas
How do i console log the results inside the subscribe?

In my angular app i am calling a service and fetching the data, i need to add a console log once the results are fetched. where can i add console log?

 this.searchTerm.asObservable()
            .debounceTime(300)      
            .distinctUntilChanged() 
            .switchMap(term => this.doFind(term))
            .subscribe(data => this.results = data
            , error => {
                this.errorMessage = error;
            });
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Use a code block

this.searchTerm.asObservable()
        .debounceTime(300)      
        .distinctUntilChanged() 
        .switchMap(term => this.doFind(term))
        .subscribe(data => {
           this.results = data;
           console.log('data', data);
        })
        , error => {
            this.errorMessage = error;
        });

or the do operator

 this.searchTerm.asObservable()
        .debounceTime(300)      
        .distinctUntilChanged() 
        .switchMap(term => this.doFind(term))
        .do(val => condole.log(val))
        .subscribe(data => this.results = data
        , error => {
            this.errorMessage = error;
        });
over 4 years ago · Santiago Trujillo Denunciar

0

You are using the shorthand version of the arrow function, use the bigger version :)

.subscribe((data) => {
     this.results = data;
     console.log(data);
 }, error => {
    this.errorMessage = error;
 });
over 4 years ago · Santiago Trujillo Denunciar

0

u can do like this

  this.searchTerm.asObservable()
        .debounceTime(300)      
        .distinctUntilChanged() 
        .switchMap(term => this.doFind(term))
        .subscribe(
            data=>this.message=data.msg,
            error=>alert('errer'),
            ()=>{console.log('finished');}

            );
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