I could swear that res.send and res.json would pretty-print the output as default when I used it before. However, I can't seem to get it to work this time. I also read that app.locals.pretty=true;
should do it as well, but I can't seem to get it to work.
Here's some sample code:
var express = require('express'); var app = express();
var sample_data ={
widget: {
child: {
title: "Sample Konfabulator Widget",
name: "Das Widget",
}
} };
app.locals.pretty = true;
app.get('/pretty', function(req, res){
res.json(sample_data); });
var port = process.env.PORT || 4000;
app.listen(port, function(){
console.log('Listening on port ' + port); });
Aucun commentaire:
Enregistrer un commentaire