Skip to content

Commit

Permalink
Fix getNetworkInterfaces response returning a non-array
Browse files Browse the repository at this point in the history
when only one network inteface is returned.
The returned object is now the Array of network interfaces (as declared in the JSDoc) instead of an object containing the array.
  • Loading branch information
Jessy committed Feb 20, 2020
1 parent 1a99557 commit 45e6db9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ module.exports = function(Cam) {
/**
* @callback Cam~GetNetworkInterfacesCallback
* @property {?Error} error
* @property {Array.<Cam~NetworkInterface>} network interfaces information
* @property {Array.<Cam~NetworkInterface>} networkInterfaces Network interfaces information
* @property {string} xml Raw SOAP response
*/

Expand All @@ -202,7 +202,10 @@ module.exports = function(Cam) {
this._envelopeFooter()
}, function(err, data, xml) {
if (!err) {
this.networkInterfaces = linerase(data).getNetworkInterfacesResponse;
this.networkInterfaces = linerase(data).getNetworkInterfacesResponse.networkInterfaces;
// networkInterfaces is an array of network interfaces, but linerase remove the array if there is only one element inside
// so we convert it back to an array
if (!Array.isArray(this.networkInterfaces)) {this.networkInterfaces = [this.networkInterfaces];}
}
if (callback) {
callback.call(this, err, this.networkInterfaces, xml);
Expand Down

0 comments on commit 45e6db9

Please sign in to comment.