I was using a library "async/await", which included an await() function that you would use like this inside a sync function/method
const await = require('asyncawait/await')
// An example class method
getUser(username) {
const user = await(this.getUserFromDb(username))
if (user) {
return user
} else {
throw "User does not exist"
}
}
async getUserFromDb(username) {
// Get user from database
}
But now, "async/await" is no longer usable in node16 because of "fibers" not working.
I still need to have a sync method, that uses an async method inside of it and returns a definitive value, not a promise. How can I do that?