app.js
app.set('json spaces', 4);
You're going to have to set the Content-Type to application/json like this
app.get('/', function (req, res) {
users.find({}).toArray(function(err, results){
res.header("Content-Type",'application/json');
res.send(JSON.stringify(results, null, 4));
});
});
node and express send json formatted
node and express send json formatted
I'm trying to send formatted json with express. Here is my code: var app = express(); app.get('/', function (req, res) { users.find({}).toArray(function(err, results){ // I have try both ...
stackoverflow.com