networkInterface


#1

I tried code from manual:

  this.networkInterface.getWiFiIPAddress(function (ip) { alert(ip); });
  this.networkInterface.getCarrierIPAddress(function (ip) { alert(ip); });

but fail compile & highlight error in IDE:

[ts] Expected 0 arguments, but got 1.
(method) NetworkInterface.getWiFiIPAddress(): Promise< string >

After call as promise:

    this.networkInterface.getWiFiIPAddress().then(result => {
      console.log(result);
    });

result has type Object
{ip: 123.123.123, subnet: 255.255.255.0}

After call console.log(result.ip); I received “[ts] Property ‘ip’ does not exist on type ‘string’.”

how to use this plugin correctly?
thanks.


#2

Manual code are not always right , you have to convert it sometimes.

Are you doing console.log(result.ip) inside promise.
try console.log(result[‘ip’])

Actually by looking at this error [ts] Expected 0 arguments, but got 1.
(method) NetworkInterface.getWiFiIPAddress(): Promise< string >
it should return a string , but as you said it returns an object .Its definitely funny behavior . i personally have never tried that plugin .


#3

Thank you!
I’ve been searching for an answer on this for a couple of days - and this finally worked!

this.networkinterface.getWiFiIPAddress().then(res => {
this.wifiIP = res[‘ip’];
}).catch(err => {
alert('err = ’ + err);
});