Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

380
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!