Answer the question
In order to leave comments, you need to log in
Nodejs how to write server response to variable?
I make a request to the server, how to correctly write the response to a variable?
let str;
const net = require('net');
const client = net.createConnection({
host: '127.0.0.1',
port: 3545
}, () => {
client.write('status\r\n');
});
client.on('data', (data) => {
str = data;
client.end();
});
client.on('end', () => {
});
console.log(str)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question