agsh / onvif

ONVIF node.js implementation
https://onvif.pages.dev
MIT License
703 stars 240 forks source link

Error on resolving response data from getPreset() #14

Closed scaret closed 9 years ago

scaret commented 9 years ago

For my camera, when there's only 1 preset or even no preset, the result of linerase(data).getPresetsResponse.preset (in ptz.js, line 32) will not be an array(instead, its an empty string for 0, and an object for 1), thus no forEach method.

TypeError: undefined is not a function
    at null.<anonymous> (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\lib\ptz.js:33:45)
    at C:\Users\Derek\temp\camera-onvif\node_modules\onvif\lib\utils.js:86:5
    at Parser.<anonymous> (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js\lib\xml2js.js:432:18)
    at Parser.emit (events.js:107:17)
    at Object.onclosetag (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js\lib\xml2js.js:401:26)
    at emit (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js\node_modules\sax\lib\sax.js:615:33)

    at emitNode (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js\node_modules\sax\lib\sax.js:620
:3)
    at closeTag (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js\node_modules\sax\lib\sax.js:861
:5)
    at Object.write (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js\node_modules\sax\lib\sax.js
:1294:29)
    at Parser.exports.Parser.Parser.parseString (C:\Users\Derek\temp\camera-onvif\node_modules\onvif\node_modules\xml2js
\lib\xml2js.js:451:31)
agsh commented 9 years ago

Fixed this in github master version