Http requests in email
I am making a desktop application with an electron where I need to make an HTTP request to php to close the session on the server.
The thing is, the session is closing fine, but the content inside http.get (options, function (res) {} doesn't work, it looks like I'm not entering here
I leave the code below for you
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);
});
+3
source to share
No one has answered this question yet
Check out similar questions: