no message

This commit is contained in:
2018-03-09 04:05:50 -05:00
parent e387be003b
commit 78399b5d1d

View File

@@ -5,7 +5,8 @@ import 'rxjs/add/operator/map';
@Injectable() @Injectable()
export class ProfileService { 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; idMap: any;
profiles: any; profiles: any;
@@ -22,14 +23,24 @@ export class ProfileService {
return new Promise(resolve => { return new Promise(resolve => {
this.http.get(this.endpoint) this.http.get(this.endpoint)
.map(res => res.json()) .map(res => res.json())
.subscribe(data => { .subscribe(
data => {
this.profiles = data; this.profiles = data;
this.profiles.reduce((map, profile, i) => { this.profiles.reduce((map, profile, i) => {
map[profile._id] = i; map[profile._id] = i;
return map; return map;
}, this.idMap); }, this.idMap);
resolve(this.profiles); 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);
}
);
}); });
} }