0

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?

JameEnder
  • 49
  • 6
  • 1
    `"async/await" is no longer usable in node16` you sure? – Bravo Jul 09 '21 at 10:50
  • I very much doubt `await` is no longer supported in Node 16. https://node.green – Jeremy Thille Jul 09 '21 at 10:57
  • I'm kinda sure its not supported anymore, i was talking about this package https://www.npmjs.com/package/asyncawait Which works on fibers, which are no longer supported, here https://github.com/laverdet/node-fibers – JameEnder Jul 10 '21 at 11:03

0 Answers0