delian / node-unifiapi

UniFi API ported to Node.JS
GNU General Public License v3.0
49 stars 19 forks source link

Simple Example not working #7

Open GadgetUK opened 6 years ago

GadgetUK commented 6 years ago

Using the following

let UnifiAPI = require('node-unifiapi'); let unifi = UnifiAPI({ baseUrl: 'https://127.0.0.1:8443', // The URL of the Unifi Controller username: 'ubnt', password: 'ubnt', debug: true, // More debug of the API (uses the debug module) // debugNet: true // Debug of the network requests (uses request module) }); unifi.login(username, password) .then(data => console.log('success', data)) .catch(err => console.log('Error', err))

I get the following output

root@gateway:~/unifi_tools# node --use-strict ./ap.js /root/node_modules/node-unifiapi/index.js:68 UnifiAPI.prototype.netsite = function(url = '', jsonParams = undefined, headers = {}, method = undefined, site = undefined) { ^

SyntaxError: Unexpected token = at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/root/unifi_tools/ap.js:1:78) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)

delian commented 6 years ago

What version of Node.JS are you using? It complains for capability enabled with ES6, so I am curious if you are using relatively old version of the node engine.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters

Delian

On Mon, Jan 1, 2018 at 2:13 PM, GadgetUK notifications@github.com wrote:

Using the following

let UnifiAPI = require('node-unifiapi'); let unifi = UnifiAPI({ baseUrl: ' https://127.0.0.1:8443', // The URL of the Unifi Controller username: 'ubnt', password: 'ubnt', debug: true, // More debug of the API (uses the debug module) // debugNet: true // Debug of the network requests (uses request module) }); unifi.login(username, password) .then(data => console.log('success', data)) .catch(err => console.log('Error', err))

I get the following output

root@gateway:~/unifi_tools# node --use-strict ./ap.js /root/node_modules/node-unifiapi/index.js:68 UnifiAPI.prototype.netsite = function(url = '', jsonParams = undefined, headers = {}, method = undefined, site = undefined) { ^

SyntaxError: Unexpected token = at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/root/unifi_tools/ap.js:1:78) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/7, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZoVtvYME8jvHRYZRUMk6In-tNmNYks5tGNnhgaJpZM4RQEep .

GadgetUK commented 6 years ago

Ok, currently 4.8.x will look at updating to see if this resolves it.

delian commented 6 years ago

I think you should use at least 6.x. The minimal version for the webrtc module is 6.9 I believe

On Wed, 3 Jan 2018 at 11:17, GadgetUK notifications@github.com wrote:

Ok, currently 4.8.x will look at updating to see if this resolves it.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/7#issuecomment-354977553, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7Zmb7uNYM-nfrb8NHf5HDxJ_o2lF-ks5tG1O-gaJpZM4RQEep .

--

Delian