I'm currently facing an issue where a function that should return a value is not being passed on to another function. Below is the code snippet in question:
public _getProfileToUpdate() {
return {
corporateId: this.storeService.setStoreData().profile.preferred_username[1],
id: this.storeService.setStoreData().profile.sub,
firstName: this.userFormGroup.controls.firstName.value,
lastName: this.userFormGroup.controls.lastName.value,
email: this.userFormGroup.controls.email.value,
mobile: this.userFormGroup.controls.mobile.value,
workNumber: this.userFormGroup.controls.workNumber.value,
roleId: this.sortRoleId()
};
}
sortRoleId() {
this._contentService._getRoles().subscribe((resp) => {
const search = this.storeService.setStoreData().profile.role;
const index = Object.values(resp.roles).indexOf(search);
const result = Object.keys(resp.roles)[index];
return result;
})
}
I am trying to send the "result" value to the "roleId" field in the other function, but it seems to be returning as undefined.