I am trying to simply handle simple POST requests and add data to a local file. However, when I try to send the POST source code from postman , for example, "hello world", what is actually added is [object Object] . I'm not sure what could be the reason for this if nothing should be interpreted as an object from both ends. Thanks!
var express = require('express'), fs = require('fs') url = require('url'); var app = express(); app.configure(function(){ app.use('/public', express.static(__dirname + '/public')); app.use(express.static(__dirname + '/public')); app.use(express.bodyParser()); }); app.post('/receive', function(request, respond) { filePath = __dirname + '/public/data.txt'; fs.appendFile(filePath, request.body, function () { respond.end(); }); }); app.listen(8080);
source share