I’m looking for the correct way to remove Promise.await
from my usage of Accounts.onCreateUser
and Accounts.emailTemplates.verifyEmail
.
In Meteor 2.8, are there async versions of these functions? I don’t see references to calling them async yet in the 2.8 Meteor docs.
As an example of what I’m trying to do, I tried this:
Accounts.onCreateUser((options, user) => {
async function manageAsynOperations(options, user) {
let args = {};
args.id = user._id;
args.name_first = options.first_name;
args.name_last = options.last_name;
const newEPUser = await connectors.epUserData.create(args);
if (args.name_first){
let sql = `UPDATE "epUserDatum"
SET "epUserNumber" = nextval('epUserNumber_seq')
WHERE "id" = '${args.id}';`
console.log("checkpoint# 7");
let results = await getQueryResults(sql);
}
console.log("checkpoint# 8");
return new Promise((resolve, reject) => {
console.log("checkpoint# 8b");
resolve(user)
})
}
console.log("checkpoint# 9");
user = manageAsynOperations(options, user);
console.log("checkpoint# 10");
return user;
});
I need all the async calls to finish before the function exits. So of course, this did not work, as the function exits (“checkpoint# 10”) before the async calls have finished (“checkpoint# 8”).