Skip to content

Commit

Permalink
Fix error 'Failed to initialize the device: TypeError: profiles.forEa…
Browse files Browse the repository at this point in the history
…ch is not a function'

root cause is that the profiles in response is not a list.
  • Loading branch information
seudut committed Nov 15, 2017
1 parent fe2f617 commit 624e3b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/modules/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -646,4 +647,4 @@ OnvifDevice.prototype._mediaGetSnapshotUri = function() {
return promise;
};

module.exports = OnvifDevice;
module.exports = OnvifDevice;

0 comments on commit 624e3b9

Please sign in to comment.