Hallo ich habe einen Effekt und möchte Fehler richtig behandeln. Ich möchte eine zusätzliche Aktion mit dem Inhalt meines serverseitigen Fehlers aufrufen. Wie könnte ich das tun?
@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);
})
)
)
);
Lösung des Problems
Leider hat niemand geantwortet, aber das funktioniert trotzdem:
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);
}
}
Keine Kommentare:
Kommentar veröffentlichen