0

The promise.resolve has two parameters. But when use async/await, I only get the first para, how can I get all of two parameters?

const a = () => new Promise((resolve, reject) => {
    resolve({a: 1}, {b: 2});
}).catch((rerr) => {
    logger.error(rerr.stack);
    return null;
});

async function b() {
    console.log(await a());
}

b();
jinsihou
  • 161
  • 1
  • 9
  • 1
    Combine them into a single object? The [resolve API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) clearly states that it supports only one argument. – Cosmin Ababei Jun 15 '17 at 07:17
  • An `await` expression - like any expression - can only result in a single value. What did you expect, an array? Then pass one to `resolve`. – Bergi Jun 15 '17 at 07:31

0 Answers0