refactor(sql): improved the return function to show data [] when not connected, prevents crashes
This commit is contained in:
@@ -9,8 +9,8 @@ import { createLog } from "../../logger/logger.js";
|
||||
|
||||
export const assignedPrinters = async () => {
|
||||
createLog("debug", "ocp", "ocp", "Lot assignment check");
|
||||
const { data: l, error: lotError } = await tryCatch(getLots());
|
||||
|
||||
const { data: lot, error: lotError } = await tryCatch(getLots());
|
||||
const l: any = lot;
|
||||
if (lotError) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -43,7 +43,7 @@ export const assignedPrinters = async () => {
|
||||
}
|
||||
|
||||
const printers: any = print.data ?? [];
|
||||
const lots: any = l?.data.length === 0 ? null : l?.data;
|
||||
const lots: any = l?.data.length === 0 ? [] : l?.data;
|
||||
|
||||
//console.log(lots);
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ export const getMac = async (machine: string) => {
|
||||
let mac = [];
|
||||
|
||||
try {
|
||||
mac = await query(updateQuery, "Machine id check");
|
||||
const getMac: any = await query(updateQuery, "Machine id check");
|
||||
|
||||
mac = getMac.data;
|
||||
// console.log("Machine data", mac); // removed due to swr being activated
|
||||
} catch (err) {
|
||||
createLog(
|
||||
|
||||
Reference in New Issue
Block a user