Why is my asynchronous function returning Promise { } instead of a value?

The promise will always log pending as long as its results are not resolved yet. You must call .then on the promise to capture the results regardless of the promise state (resolved or still pending): let AuthUser = function(data) { return google.login(data.username, data.password).then(token => { return token } ) } let userToken = AuthUser(data) console.log(userToken) … Read more

Waiting for more than one concurrent await operation

TL;DR Don’t use the pattern in the question where you get the promises, and then separately wait on them; instead, use Promise.all (at least for now): const [value1, value2] = await Promise.all([getValue1Async(), getValue2Async()]); While your solution does run the two operations in parallel, it doesn’t handle rejection properly if both promises reject. Details: Your solution … Read more

Correct Try…Catch Syntax Using Async/Await

It seems to be best practice not to place multiple lines of business logic in the try body Actually I’d say it is. You usually want to catch all exceptions from working with the value: try { const createdUser = await this.User.create(userInfo); console.log(createdUser) // business logic goes here } catch (error) { console.error(error) // from … Read more