0
Good afternoon, guys, I have two methods, how do I wait for a method that is calling an external service to respond to continue the execution of the method that called this method? Example:
salvarUsuario(){
this.usuario = formUsuario.value();
this.pegarEndereco(this.usuario.cep);
this.usuarioService.salvar().subscribe();
}
pegarEndereco(cep: string){
this.cepService.buscarPorCep(cep).subscribe((response: any) => {
this.usuario.endereco = response;
});
}
In that case, I just want to continue the execution after the takeAddress() reply.
Note: I didn’t want to make the call inside the cepService subscribe.search)
you have to create an observable, from a read: https://angular.io/guide/observables
– veroneseComS
Have to do inside the subscribe pq is asynchronous
– Eduardo Vargas