I have a method called createCal
within the ngOnInit
function. After createCal
is executed, I want to run createDefault()
after the loop has been executed three times. Following that, other codes should execute that come after createCal
. I am receiving a warning message saying that 'await' has no effect on the type of this expression.
ngOnInit() {
this.createCal();
..
}
async createCal()
{
let response=await this.commonService.getAllList().toPromise();
if(response?.length==0)
{
let res=await this.createDefault();
}
}
createDefault()
{
let defaultList=['Test 1','Test 2','Test 3'];
for(let i=0;i<defaultList.length;i++)
{
if(defaultList[i])
{
let Json = {
Id: defaultList[i],
}
this.commonService.create(Json).subscribe(async (x: any) => {
})
}
}
}