Hi , I’m using plugins like Ionic Native File and Cordova Wifiwizard.
I have the following methods
getmap() {
File.readAsText(this.storageDirectory + "/MyIonicApp", "mapa.txt").then((map) => {
var array = [];
var mapa1 = eval('(' + map + ')');
for (var i in mapa1) {
var AREA = mapa1[i]["AREA"];
var BSSID = mapa1[i]["BSSID"];
var AVG_RSSI = mapa1[i]["AVG_RSSI"];
array.push({ AREA: AREA, BSSID: BSSID, AVG_RSSI: AVG_RSSI });
}
alert("Este é o mapa do telemóvel: " + JSON.stringify(array));
}, (err) => { alert("nao da para ler") });
}
getallNetworks() {
WifiWizard.startScan(
(data) => {
WifiWizard.getScanResults(this.listHandler, (data) => { //alert(data)
})
},
(error) => {
}
);
}
listHandler(b = {}) {
var array = [];
for (var i in b) {
var BSSID = b[i].BSSID;
var level = b[i].level;
array.push({ BSSID: BSSID, level: level });
}
alert("rastreio redes wifi " + JSON.stringify(array));
}
They work, I get the response I want, but I need to use that response (in both cases its the built array) outside this functions. I tried to atribute the respective value to a global var or pass them as parameter to another function and nothing, it’s like the value is stuck inside the function I will appretiate any help!