The problem is that api.deleteUser
returns null (status 204), so the user is lost. How to pass the user (which is action.payload
) to DeleteUserSuccess(user)
?
@Effect()
public deleteUser$: Observable<Action> = this._actions$
.ofType(DELETE_USER_PENDING)
.pipe(
switchMap((action: IAction<User>) =>
this.api.deleteUser((action.payload as User).id)),
map((user: User) => new DeleteUserSuccess(user)),
catchError((err: Error, caught: Observable<Action>) => {
console.log(err);
return caught;
})
);