I'm doing a desktop application with electron where I need to make an http request to a php to close the session on the server.
The case is, that the session closes perfectly but the content that is inside http.get (options, function (res) {} does not work, it's like I do not enter here
I leave you the code below
var http = require('http');
var options = {
host: localStorage.getItem('server'),
port: localStorage.getItem('port'),
path: localStorage.getItem('directori') + '?nosession=1&call=ciberFiSessio&numSerie='+ localStorage.getItem("pc")
};
http.get(options, function(res) {
alert("hola");
if (res.statusCode == 200) {
alert("hola");
//reinicia();
res.on('data', function (chunk) {
str = chunk;
alert(str);
var myJSON = JSON.parse(str);
//alert(myJSON.fi);
if (parseInt(myJSON.fi)==0){
alert("Hi ha hagut un problema!");
} else {
reinicia();
}
});
} else {
alert("El lloc ha caigut!");
alert(res.statusCode);
}
}).on('error', function(e) {
alert("Hi ha un error: " + e.message);
});