Using Angular 4.3.1 and HttpClient, I need to modify the request and response by async service into the HttpInterceptor of httpClient,
Example for modifying the requ
I think that there is a issue about the reactive flow. The method intercept expects to return an Observable and you have to flatten your async result with the Observable returned by next.handle
Try this
intercept(req: HttpRequest, next: HttpHandler): Observable> {
return this.asyncService.applyLogic(req).mergeMap((modifiedReq)=> {
const newReq = req.clone(modifiedReq);
return next.handle(newReq);
});
}
You could also use switchMap instead of mergeMap