REST with NodeJS

49 views
Skip to first unread message

Jesus Alvarado

unread,
Jul 20, 2015, 1:39:52 PM7/20/15
to nod...@googlegroups.com
this is the code

// Load the http module to create an http server.
var http = require('http');

// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'application/json'});
    response.write('{ "posts": [');
    response.write('] }');
        response.end();
});

// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8081);

// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");


In the Browser i obtain text/html, but I need text/plain


Reply all
Reply to author
Forward
0 new messages