Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed requests stops execution with await #164

Closed
akvaliya opened this issue Feb 13, 2019 · 2 comments
Closed

Failed requests stops execution with await #164

akvaliya opened this issue Feb 13, 2019 · 2 comments

Comments

@akvaliya
Copy link

I have error interceptor like below

RestangularProvider.addErrorInterceptor((response) => {

    const error = EnumerableFromObject(response.error.Errors)
      .Select(i => i.Value.Message)
      .FirstOrDefault();
    toastr.error(error, "Error");

    return true;
  });
}

Below is code of my auth service

  async Login(login: string, password: string) {
    const sessions = this.rest.all("sessions");
    const params = {Login: login,Password: password };
    const response = await sessions.post(params).toPromise();
    return response;
  }

And this is how i am calling it in my component

this.loader.show();
const response = await this.authorizationService.Login(login, password);
this.loader.hide();

So i have to hide loader after service is completed failed or not.

My issue is when request fails with any reason like wrong credentials execution stops & it never reaches to this.loader.hide();

How to handle this without using then. In my project all methods are called with await. so i can't remove await & use then. It will require so much rework.

Anyone can tell me what am i missing here?

@victorsosa
Copy link

this is related to the #162 issue

@rshchpkn
Copy link
Collaborator

@akvaliya Please check @victorsosa solution works for you, if not please notify me so I could reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants