Within my Angular 6 application, I am facing an issue with a variable named "permittedPefs" that is assigned a value after an asynchronous HTTP call.
@Injectable()
export class FeaturesLoadPermissionsService {
permittedPefs = [];
constructor() {
this.loadUserPefsService.getUserRolePefs(roleId)
.subscribe(
(returnedListPefs) => {
this.permittedPefs = returnedListPefs;
},
error => {
console.log(error);
});
}
}
In another function, I am utilizing the same variable: permittedPefs.
However, since it starts off empty and gets populated at a delayed time, I need to wait for it before reusing it.
I attempted implementing async-await, where my objective is to ensure that permittedPefs has obtained an object value:
async checkPefPresence(pefId) {
const listPefs = await this.permittedPefs
}
What steps should be taken to resolve this issue?