Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda