diff --git a/src/vistor-password/services/visitor-password.service.ts b/src/vistor-password/services/visitor-password.service.ts index 81f2a62..b8710fa 100644 --- a/src/vistor-password/services/visitor-password.service.ts +++ b/src/vistor-password/services/visitor-password.service.ts @@ -499,17 +499,29 @@ export class VisitorPasswordService { }); const devicesData = await Promise.all( devices?.map(async (device) => { - return { - productUuid: device.productDevice.uuid, - productType: device.productDevice.prodType, - ...(await this.deviceService.getDeviceDetailsByDeviceIdTuya( - device.deviceTuyaUuid, - )), - uuid: device.uuid, - } as GetDeviceDetailsInterface; + try { + const deviceDetails = + await this.deviceService.getDeviceDetailsByDeviceIdTuya( + device.deviceTuyaUuid, + ); + return { + productUuid: device.productDevice.uuid, + productType: device.productDevice.prodType, + ...deviceDetails, + uuid: device.uuid, + } as GetDeviceDetailsInterface; + } catch (error) { + console.error( + `Error fetching details for device ${device.deviceTuyaUuid}:`, + error, + ); + // Return null or a specific value to indicate the error + return null; + } }), ); - return devicesData; + // Filter out null values to only include successful device data + return devicesData.filter((deviceData) => deviceData !== null); } async addOnlineTemporaryPasswordOneTime(