1

It seems to work but I can't find any documentation supporting it.

Example:

async function someTask() {
    // asynchronous task
    const data = await fetch();
    const modifiedData = doSomeWorkOnTheData(data);
    // NOT a promise
    return modifiedData;
}

async function caller() {
    // does this line wait for the return of the async function
    // even when it does not explicitly return a Promise?
    const someData = await someTask();
}

Basic question, I know - but I just want to be sure.

Mmm Donuts
  • 9,551
  • 6
  • 27
  • 49
  • 4
    The function returns a promise. `await` automatically resolves the promise to the resolved value. – Get Off My Lawn Aug 07 '19 at 16:09
  • I just saw that here (https://stackoverflow.com/questions/35302431/async-await-implicitly-returns-promise). I didn't know it wrapped the return value automatically. Sorry for the lame question! Thanks : ) – Mmm Donuts Aug 07 '19 at 16:10

0 Answers0