Inject dependencies

In order to make API calls, you will be leveraging the HttpClient module in Angular. The official documentation (https://angular.io/guide/http) explains the benefits of this module succinctly:

"With HttpClient, @angular/common/http provides a simplified API for HTTP functionality for use with Angular applications, building on top of the XMLHttpRequest interface exposed by browsers. Additional benefits of HttpClient include testability support, strong typing of request and response objects, request and response interceptor support, and better error handling via APIs based on Observables."

Let's start with importing the HttpClientModule in to our app, so we can inject the HttpClient within the module into the WeatherService ...

Get Angular 6 for Enterprise-Ready Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.