2017-12-15 14 views
0

api.deleteUser은 null (상태 204)을 반환하므로 사용자는 손실됩니다. 사용자 (action.payload)를 DeleteUserSuccess(user)으로 전달하는 방법은 무엇입니까?엔티티를 반환하지 않는 API 삭제 호출에 대해 @effect를 다시 쓰는 방법은 무엇입니까?

@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; 
    }) 
    ); 

답변

0

나는 해결책

@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; 
     }) 
     ); 
을 발견했습니다