Hello ,
I just start to work with nodfe-js (I have never program in JS before) , so maybe the question is dumb…
I jsut wnat to enter my router and get a variable called SIM
this is what I worte (after looked up over the internet )
var api = require('mikronode');
var sim=""
var connection = new api('10.0.0.1','admin','MyPassword');
connection.connect(function(conn) {
var chan=conn.openChannel();
chan.write(['/system/script/environment/print\n?name=SIM\n=.proplist=value'],
function() {
chan.on('trap',function(data) {
console.log('No Such Data!: ' +data);
});
chan.on('done',function(data) {
sim=data[0][0].value;
console.log("SIM number is " + sim);
});
chan.close();
conn.close();
});
});
the error I’m getting is :
node ConnectToRouter.js
/home/pi/Documents/node_modules/mikronode/dist/mikronode.js:474
_parsed$.set(this, _sentence$.get(this).do(function (d) {
^
TypeError: _sentence$.get(...).do is not a function
at new SocketStream (/home/pi/Documents/node_modules/mikronode/dist/mikronode.js:474:52)
at MikroNode.connect (/home/pi/Documents/node_modules/mikronode/dist/mikronode.js:330:30)
at Object.<anonymous> (/home/pi/Documents/ConnectToRouter.js:4:12)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
what am I doing wrong?
what is missing?
I have also try the first example in the WiKi
var api = require('mikronode');
var connection = new api('10.0.0.1','admin','MyPassword');
connection.connect(function(conn) {
var chan=conn.openChannel();
chan.write('/ip/address/print',function() {
chan.on('done',function(data) {
var parsed = api.parseItems(data);
parsed.forEach(function(item) {
console.log('Interface/IP: '+item.interface+"/"+item.address);
});
chan.close();
conn.close();
});
});
});
But I get the same error
Thanks ,