I encountered an error interceptor that looks like this:
RestangularProvider.addErrorInterceptor((response) => {
const error = EnumerableFromObject(response.error.Errors)
.Select(i => i.Value.Message)
.FirstOrDefault();
toastr.error(error, "Error");
return true;
});
}
Here is a snippet of my auth service code:
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 the way I am invoking it in my component:
this.loader.show();
const response = await this.authorizationService.Login(login, password);
this.loader.hide();
My current challenge is when a request fails due to any reason, such as incorrect credentials, the execution stops before reaching this.loader.hide();
How can I address this issue without using then
? All methods in my project are invoked with await
, so switching to then
would involve significant rework.
If anyone has suggestions on what might be missing or how to resolve this, please share.