Now, we can implement the GET call in the Weather service:
- Add a new function to the WeatherService class named getCurrentWeather
- Import the environment object
- Implement the httpClient.get function
- Return the results of the HTTP call:
src/app/weather/weather.service.tsimport { environment } from '../../environments/environment'...export class WeatherService { constructor(private httpClient: HttpClient) { } getCurrentWeather(city: string, country: string) { return this.httpClient.get<ICurrentWeatherData>( `${environment.baseUrl}api.openweathermap.org/data/2.5/weather?` + `q=${city},${country}&appid=${environment.appId}` ) }}