Here is my code.
let getMessage= await super.getResources(ctx, Flash, {where: {created_by: ctx.meta.userId}});
if(getMessage) {
getMessage.forEach(employee);
async function employee(item:any){
console.log('Inside 1');
if(item.effective_employees.length){
console.log('Inside 2');
for(let i=0;i<=(item.effective_employees.length -1);i++){
let sql:string=`sqlQuery`;
let data:any = await UserRepository.execQuery(ctx,Flash,sql);
//let data = 1;
console.log('Inside 3');
if(data){
console.log('Inside 4');
item.effective_employees[i] = 'Data here from a function';
console.log(item.effective_employees);
}
}
//return item;
}
}
console.log('Inside 5');
return Promise.resolve(getMessage);
If i am not using these lines or commenting out thease the return has Data here from a function
in it.
//let sql:string=`sqlQuery`;
//let data:any = await UserRepository.execQuery(ctx,Flash,sql);
But if i use this without commenting the return type does not have Data here from a function
In it.
I think my function is not waiting for the await and just passing the value which is there. How can I fix this?