Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 1.45 KB

http-setup-server-communication.md

File metadata and controls

30 lines (18 loc) · 1.45 KB

HTTP: Setup for server communication

Before you can use HttpClient, you need to import the Angular HttpClientModule. Most apps do so in the root AppModule.

You can then inject the HttpClient service as a dependency of an application class, as shown in the following ConfigService example.

The HttpClient service makes use of observables for all transactions. You must import the RxJS observable and operator symbols that appear in the example snippets. These ConfigService imports are typical.

You can run the that accompanies this guide.

The sample app does not require a data server. It relies on the Angular in-memory-web-api, which replaces the HttpClient module's HttpBackend. The replacement service simulates the behavior of a REST-like backend.

Look at the AppModule imports to see how it is configured.

@reviewed 2022-11-03