i have created below code to get some data, i am returning that data in a function and i am calling that function in a variable like below :
let tmsValue = await GetTMS(fymcl,this.model);
console.log("tmsValue",tmsValue);
let tms;
var GetTMS = async function getTMS(yearMetricCombo, modelData) : Promise<any>{
return new Promise((resolve, reject)=>{
modelData
.query("11111")
.where("fymcl").equals(yearMetricCombo) // tm|FY18|Promtions
.loadAll()
.exec((error, data) => {
if (error) {
reject(error);
} else {
tms = String(data.Items[0].attrs.uploadtms);
resolve(tms);
// console.log("tms",tms); // iam getting value over here
}
});
return tms;
});
}
The issue is let tmsValue = await GetTMS(fymcl,this.model); // this line is saying 'await' expression is only allowed within an async function.
I am not sure what i need to do.