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

272
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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