HTTP GET

We use the HTTP GET method to communicate with backend services to retrieve information from a particular URL resource. The sample code to get all listings is as follows:

getAllListings():Observable<any>
{
return this.http.get<Observable>('api/get-listing');
}

We have created a method named getAllListings, and we have explicitly mentioning the fact that the method will return an observable value of any data type. We have to pass the URL to the GET method. The URL is a mandatory value we need to pass. We can also pass optional data such as Headers, Params, reportProgress, and responseType. The GET method will return an instance of an RxJS observable, and we can subscribe to listen to the response. 

On similar terms, we can easily create HTTP calls using the POST, PUT, and DELETE methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.139.167