From 624e3b929ae331e7ef552838627e67eb74021f4d Mon Sep 17 00:00:00 2001 From: Peng Li Date: Wed, 15 Nov 2017 16:23:25 +0800 Subject: [PATCH] Fix error 'Failed to initialize the device: TypeError: profiles.forEach is not a function' root cause is that the profiles in response is not a list. --- lib/modules/device.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/modules/device.js b/lib/modules/device.js index 238149c..b0fe712 100644 --- a/lib/modules/device.js +++ b/lib/modules/device.js @@ -469,6 +469,7 @@ OnvifDevice.prototype._mediaGetProfiles = function() { reject(new Error('Failed to initialize the device: The targeted device does not any media profiles.')); return; } + profiles = [].concat(profiles) // in case profiles is not a list, then forEach below will report an error profiles.forEach((p) => { let profile = { 'token': p['$']['token'], @@ -646,4 +647,4 @@ OnvifDevice.prototype._mediaGetSnapshotUri = function() { return promise; }; -module.exports = OnvifDevice; \ No newline at end of file +module.exports = OnvifDevice;