Skip to content

Commit 51650f4

Browse files
Clean up RC1 bug workaround
1 parent 39a8a4a commit 51650f4

File tree

1 file changed

+5
-3
lines changed
  • templates/Angular2Spa/ClientApp/components/fetch-data

1 file changed

+5
-3
lines changed

templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export class FetchData {
99
public forecasts: WeatherForecast[];
1010

1111
constructor(http: Http) {
12+
// Workaround for RC1 bug. This can be removed with ASP.NET Core 1.0 RC2.
13+
let isServerSide = typeof window === 'undefined';
14+
let options: any = isServerSide ? { headers: { Connection: 'keep-alive' } } : null;
15+
1216
// TODO: Switch to relative URL once angular-universal supports them
1317
// https://github.com/angular/universal/issues/348
14-
http.get('http://localhost:5000/api/SampleData/WeatherForecasts', {
15-
headers: <any>{ Connection: 'keep-alive' } // Workaround for RC1 bug. TODO: Remove this after updating to RC2
16-
}).subscribe(result => {
18+
http.get('http://localhost:5000/api/SampleData/WeatherForecasts', options).subscribe(result => {
1719
this.forecasts = result.json();
1820
});
1921
}

0 commit comments

Comments
 (0)