Это можно сделать с помощью HttpInterceptor (если вам нужно изменить и зарегистрировать запрос)
@Injectable()
export class MyHttpInterceptor implements HttpInterceptor {
constructor() {}
intercept(req: HttpRequest < any > , next: HttpHandler): Observable < HttpEvent < any >> {
console.log("intercepted request ... ");
// Clone the request to add the new header.
const authReq = req.clone({
headers: req.headers.set("headerName", "headerValue")
});
console.log("Sending request with new header now ...");
//send the newly created request
return next.handle(authReq)
.catch((error, caught) => {
//intercept the respons error and displace it to the console
console.log("Error Occurred");
console.log(error);
//return the error to the method that called it
return Observable.throw(error);
}) as any;
}
}
больше информации здесь и здесь