0

I want to modify the response body through HttpInterceptor. When I catch the casuistic of HttpResponse, I make a clone of the response and modify the body:

return next.handle(req).pipe(
          map(resp => {
            if( resp instanceof HttpResponse) {
              const falseResp = resp.clone({body:null});
              return falseResp;
            }
            return resp;
          })
        )

falseResp contains body:null.

But the response received by the browser shows the original response.

I'm very confused about it.

Thanks.

I want to modify the response body before the browser receives it.

Mary
  • 205
  • 1
  • 2
  • 6

1 Answers1

0

there are 2 times to understand this. First, when the backend request is complete and some service response with, usually, a json. Second, when you want modify the response. The browser always show you json data clean, I mean, before that you manipulate the data.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 17 '23 at 08:14