This runs through ng build
@Injectable()
export class FoobarHttpClient extends HttpClient {
request( method: string, url: string, options?: {
body?: any;
headers?: HttpHeaders | {
[header: string]: string | string[];
};
params?: HttpParams | {
[param: string]: string | string[];
};
observe?: 'body' | 'events' | 'response'; // == HttpObserve;
reportProgress?: boolean;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean;
} ): Observable<any> {
return super.request( method, url, options );
}
}
My project is still on Angular 9, and there http.d.ts doesn't expose the internally used HttpObserve
(maybe that's now exported in Angular 10, I didn't check).
If you haven't done so already, I recommend looking into the ng HttpInterceptor
. Using an interceptor is the common approach to customize HttpClient-behavior.