• Overview
@angular/common/http

provideHttpClient

function

Configures Angular's HttpClient service to be available for injection.

API

Description

Configures Angular's HttpClient service to be available for injection.

The HttpClient service is provided in the root by default.

By default, HttpClient will be configured for injection with its default options for XSRF protection of outgoing requests. Additional configuration options can be provided by passing feature functions to provideHttpClient. For example, HTTP interceptors can be added using the withInterceptors(...) feature.

By default, HttpClient uses the fetch API to make requests. This is strongly recommended for applications that use Server-Side Rendering for better performance and compatibility. To use the XMLHttpRequest API instead, add the withXhr feature:

Jump to details