Angular HTTP - Abdelfattah Ragab - E-Book

Angular HTTP E-Book

Abdelfattah Ragab

0,0
19,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

In this book, I explain everything you need to know about connecting to backend Rest APIs from your Angular application. In this book, I will show you how to invoke different methods like GET, POST, and the like, how to use interceptors to inject an authentication token into every outgoing request, and much more. We will cover all areas of calling Rest APIs with Angular. By the end of this book, you will be able to call Rest APIs from your Angular application in any scenario. Let us get started.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 14

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Angular HTTP

Connecting to backend Rest APIs

Abdelfattah Ragab

Introduction

In this book, I explain everything you need to know about connecting to backend Rest APIs from your Angular application.

In this book, I will show you how to invoke different methods like GET, POST, and the like, how to use interceptors to inject an authentication token into every outgoing request, and much more.

We will cover all areas of calling Rest APIs with Angular.

By the end of this book, you will be able to call Rest APIs from your Angular application in any scenario.

Let us get started.

Understanding communication via HTTP

Most front-end applications need to communicate with a server via the HTTP protocol to download or upload data and access other back-end services. Angular provides a client HTTP API for Angular applications, the HttpClient service class in @angular/common/http.

Providing HttpClient

Before you can use the HttpClient in your application, you must configure it.

The HttpClient is provided with the help function provideHttpClient, which most applications include in the application providers in app.config.ts.

providers: [

provideHttpClient(),

]

};

provideHttpClient accepts a list of optional feature configurations, to enable or configure the behavior of different aspects of the client.

By default, the HttpClient uses the XMLHttpRequest API to make requests. The withFetch function switches the client to use the Fetch API instead.

fetch is a more modern API and is available in some environments where XMLHttpRequest is not supported. It has some limitations, e.g. no upload progress events are generated.

providers: [

provideHttpClient(

withFetch(),

),

]

};

HttpClient service

You can then add the HttpClient service as a dependency of your components, services or other classes.