1

I am trying to use Async Await after a promise returns a value. Unfortunately I am getting 'Parsing Error : Unexpected Token t2'.

I am not exactly sure what the issue is.

async function t1(){
  let arr1 = [1,2,3,4,5];
  const results = [];
  return db.query(query)
    .execute()
    .then(res => {
      return Promise.map(res, r =>{
        results.push(await t2(r));
      });
    return results;
  });
}

function t2(event){
   return Promise.resolve()
    .then({
      //do something
    })
    .then({
      //promise chaining. do something more
    })
}

t1();

I tried understanding from here but couldn't find a solution to my problem.

I want to resolve my promises sequentially, i.e., t2(res[0]) should be executed first. Then after it returns a value, t2([res1) should be called and so on

user3807691
  • 1,040
  • 8
  • 23

0 Answers0