Auth0 Home Blog Docs

How to wait for this.auth.login() using Angular 6

angular6

#1

I’m trying to write login code in Angular 6. My issue is I have a “navbar” component.

I have a simple login() method that calls the main auth0 login. The code looks like this:

login() {
  this.auth.login();
  <... more code here...>
}

However, I need the code to wait for the login to complete.

I have more code that needs to run after the login, but the code executes before the login is completed.

How can I do this in Angular 6?

I believe I’m supposed to subscribe or use an Observable or Promise.

Does anyone have some sample code on how to make this work?

Thanks.