One of my services contains a static method that I use for some initialization treatment.
Within this method, I need to retrieve data from a web service
@Injectable()
export class FeaturesInitializationService {
static allowedFeaturesModules: any = FeaturesInitializationService.featuresFilter();
public httpClient : HttpClient ;
constructor() {
}
static featuresFilter() {
// It is not permissible to use "this.httpClient" here
this.httpClient.get('myUrl').subscribe(
( data ) => {
console.log(data);
}
);
const testPef = true;
const featuresList = [];
if (testPef === true) {
featuresList.push(MenusModule);
} else {
featuresList.push(ChangelogModule);
}
return featuresList;
}
}
In this scenario, using this.httpClient
is prohibited within the static method
Any suggestions on how to approach this?