I want to get status from async function but it always return status undefined and than it goes to function that contains return status;
main.js
let status = addData(firstname, lastname, age, sex);
console.log(status);
data.js
static async addData(firstname, lastname, age, sex) {
try {
let txdata = await data.dataentry(firstname, lastname, age, sex);
let count = 0;
let intervalId = setInterval(async() => {
let status = await data.entryStatus(txdata);
logger.info("status %o", status);
if (status = true) {
clearInterval(intervalId);
return status;
} else {
count++;
if (count > 4) {
clearInterval(intervalId);
throw createError();
}
}
}, 500);
} catch (err) {
throw createError();
}
}