I am new to node.js programming . I am confused how the async and await works
const async = require('async');
createUser: async (user, myid) => {
let dotill = false;
let userid = null;
const getreturn = async.whilst(
function testCondition() { return dotill === false;},
async function increaseCounter(callback) {
let sr = "AB" + Math.floor(Math.random() * 99999999999) + 10000000000;
userid = sr.substr(0, 9);
await knex.raw('select * from userprofile where user_id=?', [userid]).then((res) => {
console.log(res.rowCount);
if (res.rowCount === 0) {
dotill = true;
callback;
}else{
callback;
}
});
},
function callback(err, n) {
if (err) {
return;
}
return {"done":true, "userid":userid}
}
);
console.log(getreturn);
// getreturn always undefined iam not getting and return
}
getreturn is always undefined how i will be able to return in above code or any other way to working in promise..