mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Update Angular 2 Music Store sample to latest Angular2/angular-universal and make HTTP requests work during server-side prerendering
This commit is contained in:
@@ -12,7 +12,11 @@ export class Home {
|
||||
public mostPopular: models.Album[];
|
||||
|
||||
constructor(http: Http) {
|
||||
http.get('/api/albums/mostPopular').subscribe(result => {
|
||||
// Workaround for RC1 bug. This can be removed with ASP.NET Core 1.0 RC2.
|
||||
let isServerSide = typeof window === 'undefined';
|
||||
let options: any = isServerSide ? { headers: { Connection: 'keep-alive' } } : null;
|
||||
|
||||
http.get('/api/albums/mostPopular', options).subscribe(result => {
|
||||
this.mostPopular = result.json();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user