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

271
Views
How to make api call and don't wait for response in Angular 10

I want to do a api call and dont want to wait for its response. Like below.

{
  // Some Work
  this.authService.logUserDetails(); // this will be api call for which i don't want to wait.
  // continue with some work..
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I'm not sure why you would want such a thing but in order to actually do the API call you need to subscribe to it.

   {
      // Some Work
      this.authService.logUserDetails().subscribe();
      foo();
      bar();
      baz();
    }

The code executed inside the subscribe callback will be asynchronous, meaning that the code will be executed when the response will be available. The code below the subscribe instead will be executed while the response is fetched.

about 4 years ago · Juan Pablo Isaza Report

0

What exactly do you mean? if that is an api call, you will have to subscribe to it, subscribe is already asynchronous. Its not like you dont want to wait for it. You can not wait for it, without somehow implementing promise like behaviour.

You can just go

someFunction() {
    this.authService.logUserDetails().subscribe({
        next: (response) => {
            // do smth with response
        },
        error: (error) => {
            // treat error
        }
    })

   //logic that is written here will be run before logic that is written inside subscribe
}

Have in mind that api call will not actually be done before you subscribe to it

about 4 years ago · Juan Pablo Isaza 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!