This is very strange in that Express JS is sending the console.log output to the client without res.send being used.
Calling the /api POST endpoint shows the "Hello" from the parseJSON back to the client.
How can I get this to stop?
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json({
limit: '50mb'
}));
app.use(bodyParser.urlencoded({
extended: false
}));
app.get('*', function(req, res, next) {
var err = new Error();
err.status = 404;
next(err);
});
// handling 404 errors
app.use(function(err, req, res, next) {
if (err.status !== 404) {
return next();
}
res.send(err.message || '** 404 error **');
});
app.post('/api', function(req, res) {
parseJSON(req.body);
res.status(200).end();
});
app.listen(80);
function parseJSON(jsonData)
{
console.log("HELLO");
}