0

I am trying to change response using HTTP interceptor in Angular-6

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    console.log('request', request);
    const httpsReq = request.clone({
        url: request.url.replace("http://xx.xx.xx.xx:8085/onlinetest/api/v1/signin", "http://jsonplaceholder.typicode.com/todos/1"),
        method: 'GET'
      });

    //   return of(new HttpResponse({ status: 200, body: this.returnData }));


      return next.handle(httpsReq).pipe(
        // There may be other events besides the response.
        filter(event => event instanceof HttpResponse),
        tap((event: HttpResponse<any>) => {
          return {status: 200, data: 'hello'}
        })
      );        
}

This is giving me reponse from the jsonplaceholder api, while I want to to see {status: 200, data: 'hello'}, please help.

raju
  • 6,448
  • 24
  • 80
  • 163

0 Answers0