Estoy tratando de hacer una solicitud de obtención de HTTP, pero no se devuelve nada como texto. Aquí está mi código
const http = require('http'); const ws = require('ws'); const wss = new ws.Server({noServer: true}); var XMLHttpRequest = require('xhr2'); function accept(req, res) { console.log("got request") wss.handleUpgrade(req, req.socket, Buffer.alloc(0), function(ws) { //party name, sockets on party, limit 2 ws.on('message', function (msg) { var message = JSON.parse(msg.toString()) if(message.type==='add') { //do later } else if(message.type==='start') { httpGetAsync('192.168.26.23', "/startRelay") } else if(message.type==='stop') { httpGetAsync('92.168.26.23', "/stopRelay") } else if(message.type==='status') { httpGetAsync('92.168.26.23', "/") } }); ws.on('close', function () { console.log('closed') }); ws.on('error', function(error){ console.log('error - ' + JSON.stringify(error)); }); }) } function httpGetAsync(theUrl, path) { var options = { host: theUrl, path: path, method: "GET", } callback = async function(response) { var str = '' response.on('data', function (chunk) { str += chunk; }); response.on('end', function () { console.log(JSON.parse(str)); }); }; http.request(options, callback).end(); } http.createServer(accept).listen(3000);Esto es lo que contiene 192.168.26.23 (si lo escribe desde mi wifi en Google, esto es lo que se muestra, y esta información es lo que necesito para obtener en una cadena)
{"success":true,"ms_left":0,"relayStarted":false}