deviceID + ':', error);
                                return device; // Return original device if fetch fails
                            })
                    );
                    
                    // Wait for all device details to be fetched
                    return Promise.all(devicePromises);
                } else {
                    return devices;
                }
            })
            .then(devices => {
                console.log('Final devices data with products:', devices);
    