I'am catching the error in the Subscribe and the enclosing Promise.
@Injectable()
export class CountryListResolver {
public countryList: Locale[];
constructor(private portareServices: PortareServices) { }
load() {
return new Promise((resolve, reject) => {
this.portareServices.getCountryList().subscribe((data) => {
this.countryList = data;
resolve(true);
},
error => {
console.log('CountryListResolver', error);
},
() => {
// No errors, route to new page
});
}).catch((err: any) => Promise.resolve());
}
}
Now the thing is, when I uncomment the functionality of actually getting the data from the service, the app just loads fine (obviously without having the data in place which should have neen loaded initially).
// this.localesEU = this.portareDataModel.setLocalesEU = this.countryListResolver.countryList;
App loads just fine when commented out the load function. Also, if service resolves succesfully, everything just works like a charm.
providers: [
CountryListResolver, { provide: APP_INITIALIZER, useFactory: countryListProviderFactory, deps: [CountryListResolver], multi: true }
]
How to handle this issue?
.catch((err: any) => Promise.resolve());doesPromise.reject()help?topromiseoperator learnrxjs.io/operators/utility/topromise.html