fix: #271 Cannot read properties of undefined (reading 'map')

This commit is contained in:
Louis 2023-10-08 16:23:24 +07:00 committed by Louis
parent 1a33c493e4
commit b6a58df463

View File

@ -168,7 +168,7 @@ function getFinishedDownloadModels() {
const query = `SELECT * FROM models WHERE finish_download_at != -1 ORDER BY finish_download_at DESC`;
db.all(query, (err: Error, row: any) => {
res(row.map((item: any) => parseToProduct(item)));
res(row?.map((item: any) => parseToProduct(item)) ?? []);
});
db.close();
});