Possible fix to callLogs api? Part 2
This commit is contained in:
parent
52726be732
commit
8441f0e5a5
10
index.js
10
index.js
|
|
@ -484,8 +484,18 @@ app.get("/api/v1/admin/callLogs", (req, res) => {
|
||||||
rows = rows.map(row => {
|
rows = rows.map(row => {
|
||||||
const newRow = {};
|
const newRow = {};
|
||||||
for (const key in row) {
|
for (const key in row) {
|
||||||
|
// Convert BigInt explicitly to avoid "Cannot mix BigInt and other types" errors,
|
||||||
|
// handle Dates and null/undefined safely, otherwise coerce to string.
|
||||||
|
if (typeof row[key] === 'bigint') {
|
||||||
|
newRow[key] = row[key].toString();
|
||||||
|
} else if (row[key] instanceof Date) {
|
||||||
|
newRow[key] = row[key].toISOString();
|
||||||
|
} else if (row[key] === null || row[key] === undefined) {
|
||||||
|
newRow[key] = null;
|
||||||
|
} else {
|
||||||
newRow[key] = String(row[key]);
|
newRow[key] = String(row[key]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return newRow;
|
return newRow;
|
||||||
});
|
});
|
||||||
res.json({ totalPages, page, data: rows });
|
res.json({ totalPages, page, data: rows });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue