My function return value of an array before pushing value into array.
private async getPPickerid(ppvalue,AssignedToIdArr):Promise<any> {
return new Promise<any>((resolve, reject) => {
ppvalue.forEach(async(element ,i) => {
var user = await this.GetUserIdPPicker(element.Key);
console.log(user.d.Id);
AssignedToIdArr.push(user.d.Id);
})
resolve(AssignedToIdArr);
})
Function doesn't wait for the loop to be completed for pushing the value into array.
Instead It resolved the blank array and then array. Push work.
I have used async-await but not getting any way for function to wait for loop and then get resolved