How to send formatted json in expressjs?
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 ..
Code Snippets/NodeJS
2021. 12. 8. 22:20