From 5d6440947a6fd019ed45e5fb313ceecf9b1a1d4d Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Fri, 4 Nov 2022 00:10:05 +0000 Subject: [PATCH] docs: New document extracted from the original Communicating with backend services using HTTP document, which is to be retired. (#47965) PR Close #47965 --- .../guide/http-setup-server-communication.md | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/aio/content/guide/http-setup-server-communication.md b/aio/content/guide/http-setup-server-communication.md index 4c1cf791767..25b3cfe2db2 100644 --- a/aio/content/guide/http-setup-server-communication.md +++ b/aio/content/guide/http-setup-server-communication.md @@ -1,3 +1,30 @@ -# Setup for server communication +# HTTP: Setup for server communication -@reviewed 2022-10-06 +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](guide/glossary#observable "Observable definition") 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*](https://github.com/angular/angular/tree/main/packages/misc/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