mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 18:19:40 +00:00
Make async data fetching work on the server with Angular 2
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user