Make async data fetching work on the server with Angular 2

This commit is contained in:
SteveSandersonMS
2016-04-05 20:31:21 +01:00
parent 89c8dd3b36
commit c8a7ac95a9
2 changed files with 19 additions and 8 deletions

View File

@@ -9,7 +9,11 @@ export class FetchData {
public forecasts: WeatherForecast[];
constructor(http: Http) {
http.get('/api/SampleData/WeatherForecasts').subscribe(result => {
// TODO: Switch to relative URL once angular-universal supports them
// https://github.com/angular/universal/issues/348
http.get('http://localhost:5000/api/SampleData/WeatherForecasts', {
headers: <any>{ Connection: 'keep-alive' } // Workaround for RC1 bug. TODO: Remove this after updating to RC2
}).subscribe(result => {
this.forecasts = result.json();
});
}