I'm scraping a website using Playwright. but i have a problem. every time I do a page evaluate it always returns undefined data. but when I do console log in the evaluate page, the data appears on the console page, but doesn't appear in the terminal/command line
const table= await page.$eval("#txnHistoryList > tbody", (table) => {
let arrayData = [];
if (table != null) {
const rows = Array.from(table.querySelectorAll("tr"));
rows.forEach((row, rowIndex) => {
if (rowIndex > 1) {
const td = row.querySelectorAll("td");
let arrays = {};
if (td.length > 2) {
td.forEach((item, tdIndex) => {
if (tdIndex == 1) {
const date = item.innerText;
arrays.date = date ? date.toString().trim() : "";
}
if (tdIndex == 2) {
const transaction = item.innerText;
arrays.transaction = transaction
? transaction.toString().trim()
: "";
}
if (tdIndex == 4) {
const type = item.innerText;
arrays.type = type ? type.toString().trim() : "";
}
if (tdIndex == 5) {
const paymentAmount = item.innerText;
arrays.payment_amount = paymentAmount
? paymentAmount.toString().trim()
: "";
}
if (tdIndex == 6) {
const balance = item.innerText;
arrays.balance = balance ? balance.toString().trim() : "";
}
});
arrayData.push(arrays);
}
}
});
}
console.log(arrayData);
return arrayData;
});
console.log(tableMutasi);
const data = {
data: tableMutasi,
};
res.send(data);
Please help me