using async/await to catch errors

javascript,es6,object,web_development

async function executeAsyncTask () {
  try {
    const valueA = await functionA();
    const valueB = await functionB(valueA);
    const valueC = await functionC(valueB);
    return await functionD(valueC);
  }
  catch (err) {
    logger.error(err);
  } finally {
    await alwaysExecuteThisFunction();
  }
}

Có thể bạn đã miss một số snippets code

Using promises to catch errors

using async/await to catch errors

Promise + gì

promise + gì

How to use the spread operator to flatten array of objects in javascript

How to use the spread operator to flatten array of objects in javascript

Spread Operator for Objects

Using the spread operator during an Object declaration will assign the properties of the referenced Object to the new Object.