Commit ab49d720 authored by Dennis Willers's avatar Dennis Willers 🏀

More easy way to read JSON response

parent 96d07da0
Pipeline #418 passed with stages
in 2 minutes and 45 seconds
......@@ -72,9 +72,8 @@ server.on('connection',function(socket){
vote: '30'
})
.then(res => {
console.log('Prepare: ', res.headers, res.data);
//echo data
var is_kernel_buffer_full = socket.write('content-length:'+res.headers['content-length'] + '\n\n' + JSON.stringify(res.data) + '\n');
var is_kernel_buffer_full = socket.write(JSON.stringify(res.data) + '\n');
if(is_kernel_buffer_full){
console.log('Data was flushed successfully from kernel buffer i.e written successfully!');
}else{
......@@ -225,7 +224,7 @@ const clients = net.connect({host: 'localhost', port: 3000}, () => {
clients.on('data', (data) => {
console.log(data.toString());
clients.end();
//clients.end();
});
/*clients.on('end', () => {
console.log('disconnected from server');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment