loading...

Discussion on: JS Async: async/await

Collapse
jwp profile image
John Peters

Question:

async function myAsyncFunction() {
  const payload = await { name: "felipe", age: 22 };
  console.log(payload); // { name: 'felipe', age: 22 }
}

This example creates a closure on payload of an object that is awaited. Does JavaScript automatically resolve the promise in this case?

RxJs has commands like [of, from] etc, which create promises compatible with Async/Await.

Collapse
felipesousa profile image
Felipe Sousa Author

Exactly, if the “awaited” process is a value or a function that return a value, automatically this is converted to a resolved promise.