Possible fix to callLogs api?
This commit is contained in:
parent
d0445d5103
commit
52726be732
8
index.js
8
index.js
|
|
@ -480,6 +480,14 @@ app.get("/api/v1/admin/callLogs", (req, res) => {
|
|||
conn.query("SELECT COUNT(*) as count FROM callLogs").then((rows) => {
|
||||
const totalPages = Math.ceil(rows[0].count / 100);
|
||||
conn.query("SELECT * FROM callLogs ORDER BY timestamp DESC LIMIT 100 OFFSET ?", [offset]).then((rows) => {
|
||||
// Turn all values in rows to strings, prevents type issues with bigints.
|
||||
rows = rows.map(row => {
|
||||
const newRow = {};
|
||||
for (const key in row) {
|
||||
newRow[key] = String(row[key]);
|
||||
}
|
||||
return newRow;
|
||||
});
|
||||
res.json({ totalPages, page, data: rows });
|
||||
}).catch(err => {
|
||||
console.error('Error getting call logs:', err);
|
||||
|
|
|
|||
Loading…
Reference in a new issue