no message
This commit is contained in:
@@ -5,7 +5,8 @@ import 'rxjs/add/operator/map';
|
||||
@Injectable()
|
||||
export class ProfileService {
|
||||
|
||||
endpoint: string = 'https://api.fitz.guru/urge/profiles'; //'assets/data/profiles.json';
|
||||
endpoint: string = 'https://api.fitz.guru/urge/profiles';
|
||||
fallback: string = 'assets/data/profiles.json';
|
||||
idMap: any;
|
||||
profiles: any;
|
||||
|
||||
@@ -22,14 +23,24 @@ export class ProfileService {
|
||||
return new Promise(resolve => {
|
||||
this.http.get(this.endpoint)
|
||||
.map(res => res.json())
|
||||
.subscribe(data => {
|
||||
this.profiles = data;
|
||||
this.profiles.reduce((map, profile, i) => {
|
||||
map[profile._id] = i;
|
||||
return map;
|
||||
}, this.idMap);
|
||||
resolve(this.profiles);
|
||||
});
|
||||
.subscribe(
|
||||
data => {
|
||||
this.profiles = data;
|
||||
this.profiles.reduce((map, profile, i) => {
|
||||
map[profile._id] = i;
|
||||
return map;
|
||||
}, this.idMap);
|
||||
resolve(this.profiles);
|
||||
},
|
||||
error => {
|
||||
this.profiles = this.fallback;
|
||||
this.profiles.reduce((map, profile, i) => {
|
||||
map[profile._id] = i;
|
||||
return map;
|
||||
}, this.idMap);
|
||||
resolve(this.profiles);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user