import { Component , Inject } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; @ Component ( { selector : 'app-fetch-data' , templateUrl : './fetch-data.component.html' } ) export class FetchDataComponent { public forecasts : WeatherForecast [ ] ; constructor ( http , @ Inject ( 'BASE_URL' ) baseUrl ) { http . get < WeatherForecast [ ] > ( baseUrl + 'api/SampleData/WeatherForecasts' ) . subscribe ( result => { this . forecasts = result ; } , error => console . error ( error ) ) ; } } interface WeatherForecast { dateFormatted : string ; temperatureC : number ; temperatureF : number ; summary : string ; }