1

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;
    })
    );
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ekaterina
  • 1,642
  • 3
  • 19
  • 36

1 Answers1

2

I've found the solution

@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(() => new DeleteUserSuccess(action.payload as User))),
       // map((user: User) => new DeleteUserSuccess(user)),
        catchError((err: Error, caught: Observable<Action>) => {
            // tslint:disable-next-line
            console.log(err);
            return caught;
        })
        );
Ekaterina
  • 1,642
  • 3
  • 19
  • 36