maximum call stack size exceeded in local database data fetch in for loop

54 views Asked by At

I am using awiat in for loop 2 times for data fetching from local database. Apparently it works fine but when I open and close the screen/component 4-5 times .It shows me the error. "Maximum call Stack size Exceeded"

I Have tried many solutions like promises to handle it but it still it gives me this error.

code : for (let i = 0; i < val.length; i++) { console.log('batchno', val[i].batchno); let result = await item.GetPendingCountwithbatchno(val[i].batchno); //from sqllite let result2 = await item.GetCalledphoneNumberCountswithbatchno( val[i].batchno, ); // from sql lite

  let pending = result.rows.item(0).Cnt;
  let called = result2.rows.item(0).Cnt;
  val[i].pending = pending;
  val[i].called = called;
}
console.log('val:', val);
console.log('lastindex:', lastindex);
//return val;
if (val[lastindex].pending != undefined) setbatchlist([...val]);

};

0

There are 0 answers