Issue
Hello I have an Effect and want to handle error properly. I want to call an additional action with content of my server side error. How could I do this?
@Injectable()
export class AuthEffects {
@Effect()
registerUser$ = this.actions$.pipe(
ofType(AuthActions.Action.CREATE_USER),
switchMap(({user}) =>
this.customersService.createNewUser(user).pipe(
switchMap(() => [
new ModalActions.SetModalType(null)
]
),
catchError((err) => {
if (foo) {
new ModalActions.SetModalErrors(err.error); // <---- make an Action here
} else {
}
return throwError(err);
})
)
)
);
Solution
Unfortunately nobody answered, but anyway this works:
catchError((err) => {
if (err.error.email) {
return of(new ModalActions.SetModalErrors(err.error));
} else {
this.notificationService.notify(Object.values(err.error)[0] as string);
return throwError(err);
}
}
Answered By - Dmitry
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.