Angular Rxjs map()函数';s参数为空

Angular Rxjs map()函数';s参数为空,angular,rxjs,angular7,Angular,Rxjs,Angular7,我在Angular中有以下拦截器 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { //handle response return next.handle(req).pipe( tap(evt => { if (evt instanceof HttpResponse) {

我在
Angular
中有以下
拦截器

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    //handle response
    return next.handle(req).pipe(
        tap(evt => {
            if (evt instanceof HttpResponse) {
                if (evt.status == 201) {
                    this.toastrService.success('Successfully Created', 
                    'Success', this.toastConfig);
                } 
                if (evt.status == 202) {
                    this.toastrService.success('Successfully Updated', 
                    'Success', this.toastConfig);
                } 
                if (evt.status == 204) {
                    this.toastrService.success('Successfully Deleted', 
                    'Success', this.toastConfig);
                } 
            }
            return of(evt);
        }),
        catchError((err: any) => {
            if (err instanceof HttpErrorResponse) {
                if (err.status == 401) {
                    let strMessage = err.error ? err.error.Message ? err.error.Message : "Authorization Error: You are not allowed to access the requested resource" :  "Authorization Error: You are not allowed to access the requested resource";
                    this.toastrService.warning(strMessage, "Authentication Response", this.toastConfig);
                } else if (err.status == 500) {
                    this.toastrService.error("Oops! Somethign went wrong.", "Internal Error", this.toastConfig)
                } else {
                    this.toastrService.error(err.message, "Error", this.toastConfig);
                }
            }

            return of(err);
        })
    );
}
}

我通过在组件中订阅
来执行
deleteUser()
函数,如下所示:

deleteEvent(id: number): void {
    this.userService.deleteUser(id)
       .subscribe(x => {
        if (x) {
           this.search(); //refreshes list
        }
      });
  }
我的问题是,
.pipe(map(x=>{…}
x参数为空


我正在从
拦截器返回
HttpResponse
,但是
map()
中的
userService
中没有收到响应。我想您的问题是在
点击
操作符内返回


就我所记得的,
tap
总是返回
void
,这可能是个问题,不是吗?

I supouse
.pipe(map(x=>{return(x instanceof HttpResponse&&x.status==204)?true:false})
@mbojko谢谢。我完全忘了告诉Angular我想要完整的响应,{observe:'response}
返回(evt);
不会做任何事情,但管道中的下一个操作员/订阅者将获得未更改的流。不。我需要在我的http调用选项中添加{observe:'response},告诉Angular我想要完整的HttpResponse对象backtap不会返回void,它只侦听流,根本不会修改它
deleteEvent(id: number): void {
    this.userService.deleteUser(id)
       .subscribe(x => {
        if (x) {
           this.search(); //refreshes list
        }
      });
  }