var http = require('http');
var options = {
  host: '127.0.0.1',
  path: '/',
  port: '8080',
  method: 'POST'
};
function readJSONResponse(response) {
  var responseData = '';
  response.on('data', function (chunk) {
    responseData += chunk;
  });  
  response.on('end', function () {
    var dataObj = JSON.parse(responseData);
    console.log("Niesformatowana odpowiedź: " +responseData);
    console.log("Komunikat: " + dataObj.message);
    console.log("Pytanie: " + dataObj.question);
  });
}
var req = http.request(options, readJSONResponse);
req.write('{"name":"Bilbo", "occupation":"włamywaczem"}');
req.end();