I am trying to intercept all the HttpResponse using angular interceptor as
return next.handle(request).pipe(
map((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
// do stuff with response and headers you want
event.body = event.body.data || event.body;
console.log('event--->>>', event);
}
return event;
})
);
but typescript gives an error
ERROR in src/app/shared/interceptors/auth.interceptor.ts(35,17): error TS2540: Cannot assign to 'body' because it is a read-only property.
What should I do to tackle this?
NOTE: Cloning the object using
Object.assignstill gives the same error for new object.